




'''simple docstring'''






import argparse

import torch

from transformers import ElectraConfig, ElectraForMaskedLM, ElectraForPreTraining, load_tf_weights_in_electra
from transformers.utils import logging


logging.set_verbosity_info()






def 		UpperCamelCase__			(		__SCREAMING_SNAKE_CASE							,			__SCREAMING_SNAKE_CASE							,			__SCREAMING_SNAKE_CASE							,			__SCREAMING_SNAKE_CASE		)						->      List[Any]:
      # Initialise PyTorch model
      snake_case__					:      Dict  			=						ElectraConfig.from_json_file(__SCREAMING_SNAKE_CASE		)
      print(f"Building PyTorch model from configuration: {config}"		)

      if discriminator_or_generator == "discriminator":
            snake_case__					:      Dict  			=						ElectraForPreTraining(__SCREAMING_SNAKE_CASE		)
      elif discriminator_or_generator == "generator":
            snake_case__					:      Optional[Any]  			=						ElectraForMaskedLM(__SCREAMING_SNAKE_CASE		)
      else:
            raise ValueError('The discriminator_or_generator argument should be either \'discriminator\' or \'generator\''		)

      # Load weights from tf checkpoint
      load_tf_weights_in_electra(
          __SCREAMING_SNAKE_CASE							,			__SCREAMING_SNAKE_CASE							,			__SCREAMING_SNAKE_CASE							,			discriminator_or_generator=__SCREAMING_SNAKE_CASE		)

      # Save pytorch-model
      print(f"Save PyTorch model to {pytorch_dump_path}"		)
      torch.save(model.state_dict()							,			__SCREAMING_SNAKE_CASE		)


if __name__ == "__main__":
      A_ 			=		argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          "--tf_checkpoint_path", default=None, type=str, required=True, help="Path to the TensorFlow checkpoint path."
      )
      parser.add_argument(
          "--config_file",
          default=None,
          type=str,
          required=True,
          help="The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.",
      )
      parser.add_argument(
          "--pytorch_dump_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
      )
      parser.add_argument(
          "--discriminator_or_generator",
          default=None,
          type=str,
          required=True,
          help=(
              "Whether to export the generator or the discriminator. Should be a string, either 'discriminator' or "
              "'generator'."
          ),
      )
      A_ 			=		parser.parse_args()
      convert_tf_checkpoint_to_pytorch(
          args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.discriminator_or_generator
      )






'''simple docstring'''






import bsa
import requests






def 		UpperCamelCase__			(		__SCREAMING_SNAKE_CASE		)						->      dict[str, str]:
      return {
          "name": soup.ha.a.text,
          "genre": soup.find('span'							,			class_='genre'		).text.strip(),
          "rating": soup.strong.text,
          "page_link": f"https://www.imdb.com{soup.a.get('href'		)}",
      }






def 		UpperCamelCase__			(		__SCREAMING_SNAKE_CASE = 5		)						->      tuple:
      snake_case__					:      Tuple  			=						int(float(__SCREAMING_SNAKE_CASE		)		)
      if num_movies < 1:
            return ()
      snake_case__					:      Any  			=						(
          'https://www.imdb.com/search/title?title_type='
          f"feature&sort=num_votes,desc&count={num_movies}"
      )
      snake_case__					:      Union[str, Any]  			=						bsa.BeautifulSoup(requests.get(__SCREAMING_SNAKE_CASE		).content							,			'html.parser'		)
      return tuple(
          get_movie_data_from_soup(__SCREAMING_SNAKE_CASE		)
          for movie in source.find_all('div'							,			class_='lister-item mode-advanced'		)		)


if __name__ == "__main__":
      import json

      A_ 			=		int(input("How many movies would you like to see? "))
      print(
          ", ".join(
              json.dumps(movie, indent=4) for movie in get_imdb_top_movies(num_movies)
          )
      )
