


"""simple docstring"""


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   snake_case		(     UpperCamelCase__       :						Union[str, Any]			,				UpperCamelCase__       :						List[str]			,				UpperCamelCase__       :						Any    )   ->      Tuple:
      # Construct model
      if openai_config_file == "":
            lowerCamelCase					:					Optional[Any]        =	OpenAIGPTConfig()
      else:
            lowerCamelCase					:					List[Any]        =	OpenAIGPTConfig.from_json_file(UpperCamelCase__    )
      lowerCamelCase					:					Dict        =	OpenAIGPTModel(UpperCamelCase__    )

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

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


if __name__ == "__main__":
    __lowerCamelCase      :Tuple	    =		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.'
        ),
    )
    __lowerCamelCase      :str	    =		parser.parse_args()
    convert_openai_checkpoint_to_pytorch(
        args.openai_checkpoint_folder_path, args.openai_config_file, args.pytorch_dump_folder_path
    )








"""simple docstring"""


from __future__ import annotations

__lowerCamelCase      :int	    =		10




def   snake_case		(     UpperCamelCase__       :						list[int]    )   ->      list[int]:
      lowerCamelCase					:					int        =	1
      lowerCamelCase					:					Union[str, Any]        =	max(UpperCamelCase__    )
      while placement <= max_digit:
            # declare and initialize empty buckets
            lowerCamelCase					:					list[list]        =	[[] for _ in range(UpperCamelCase__    )]
            # split list_of_ints between the buckets
            for i in list_of_ints:
                  lowerCamelCase					:					Any        =	int((i / placement) % RADIX    )
                  buckets[tmp].append(UpperCamelCase__    )
            # put each buckets' contents into list_of_ints
            lowerCamelCase					:					Dict        =	0
            for b in range(UpperCamelCase__    ):
                  for i in buckets[b]:
                        lowerCamelCase					:					List[str]        =	i
                        a += 1
        # move to next
            placement *= RADIX
      return list_of_ints


if __name__ == "__main__":
    import doctest

    doctest.testmod()




