





import argparse

import torch

from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:str   ,   SCREAMING_SNAKE_CASE		:List[Any]   ,   SCREAMING_SNAKE_CASE		:str   )      ->   Dict:
 # Construct model
 if openai_config_file == "":
  __lowerCAmelCase					:	List[Any]      =       OpenAIGPTConfig()
 else:
  __lowerCAmelCase					:	Any      =       OpenAIGPTConfig.from_json_file(SCREAMING_SNAKE_CASE   )
 __lowerCAmelCase					:	int      =       OpenAIGPTModel(SCREAMING_SNAKE_CASE   )

 # Load weights from numpy
 load_tf_weights_in_openai_gpt(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )

 # Save pytorch-model
 __lowerCAmelCase					:	Optional[int]      =       pytorch_dump_folder_path + """/""" + WEIGHTS_NAME
 __lowerCAmelCase					:	int      =       pytorch_dump_folder_path + """/""" + CONFIG_NAME
 print(F'''Save PyTorch model to {pytorch_weights_dump_path}'''   )
 torch.save(model.state_dict()   ,   SCREAMING_SNAKE_CASE   )
 print(F'''Save configuration file to {pytorch_config_dump_path}'''   )
 with open(SCREAMING_SNAKE_CASE   ,   """w"""   ,   encoding="""utf-8"""   ) as f:
  f.write(config.to_json_string()   )


if __name__ == "__main__":
      _UpperCAmelCase             =							argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          '--openai_checkpoint_folder_path',
          default=None,
          type=str,
          required=True,
          help='Path to the TensorFlow checkpoint path.',
      )
      parser.add_argument(
          '--pytorch_dump_folder_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
      )
      parser.add_argument(
          '--openai_config_file',
          default='',
          type=str,
          help=(
              'An optional config json file corresponding to the pre-trained OpenAI model. \n'
              'This specifies the model architecture.'
          ),
      )
      _UpperCAmelCase             =							parser.parse_args()
      convert_openai_checkpoint_to_pytorch(
          args.openai_checkpoint_folder_path, args.openai_config_file, args.pytorch_dump_folder_path
      )








from datetime import datetime

import requests






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:str   )      ->   bytes:
 __lowerCAmelCase					:	List[Any]      =       """https://downloadgram.net/wp-json/wppress/video-downloader/video?url="""
 __lowerCAmelCase					:	Dict      =       requests.get(base_url + url   ).json()[0]["""urls"""][0]["""src"""]
 return requests.get(SCREAMING_SNAKE_CASE   ).content


if __name__ == "__main__":
      _UpperCAmelCase             =							input('Enter Video/IGTV url: ').strip()
      _UpperCAmelCase             =							f'''{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4'''
      with open(file_name, 'wb') as fp:
            fp.write(download_video(url))
      print(f'''Done. Video saved to disk as {file_name}.''')