





"""simple docstring"""


import argparse

import torch

from transformers import ImageGPTConfig, ImageGPTForCausalLM, load_tf_weights_in_imagegpt
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()





def 							a__			(  _UpperCAmelCase	,     _UpperCAmelCase	,     _UpperCAmelCase	)    ->  List[str]:

 '''simple docstring'''






 snake_case__    							=				{"small": (5_1_2, 8, 2_4), "medium": (1_0_2_4, 8, 3_6), "large": (1_5_3_6, 1_6, 4_8)}
 snake_case__							,   snake_case__							,   snake_case__    							=				MODELS[model_size]  # set model hyperparameters
 snake_case__    							=				ImageGPTConfig(n_embd=_UpperCAmelCase	,     n_layer=_UpperCAmelCase	,     n_head=_UpperCAmelCase	)
 snake_case__    							=				ImageGPTForCausalLM(_UpperCAmelCase	)

 # Load weights from numpy
 load_tf_weights_in_imagegpt(_UpperCAmelCase	,     _UpperCAmelCase	,     _UpperCAmelCase	)

 # Save pytorch-model
 snake_case__    							=				pytorch_dump_folder_path + "/" + WEIGHTS_NAME
 snake_case__    							=				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__":
   a__					:     List[str]							=				argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       """--imagegpt_checkpoint_path""",
       default=None,
       type=str,
       required=True,
       help="""Path to the TensorFlow checkpoint path.""",
   )
   parser.add_argument(
       """--model_size""",
       default=None,
       type=str,
       required=True,
       help="""Size of the model (can be either 'small', 'medium' or 'large').""",
   )
   parser.add_argument(
       """--pytorch_dump_folder_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
   )
   a__					:     Union[str, Any]							=				parser.parse_args()
   convert_imagegpt_checkpoint_to_pytorch(
       args.imagegpt_checkpoint_path, args.model_size, args.pytorch_dump_folder_path
   )








"""simple docstring"""


from math import sqrt





def 							a__			(  _UpperCAmelCase	)    ->  list[int]:

 '''simple docstring'''






 snake_case__    							=				[1]
 for i in range(2	,     int(sqrt(_UpperCAmelCase	)	) + 1	,     1	):
  if number % i == 0:
   values.append(_UpperCAmelCase	)
   if int(number // i	) != i:
    values.append(int(number // i	)	)
 return sorted(_UpperCAmelCase	)





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 return sum(factors(_UpperCAmelCase	)	) > n





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 snake_case__    							=				factors(_UpperCAmelCase	)
 snake_case__    							=				len(_UpperCAmelCase	)
 snake_case__    							=				[[0 for i in range(number + 1	)] for j in range(r + 1	)]
 for i in range(r + 1	):
  snake_case__    							=				True

 for i in range(1	,     number + 1	):
  snake_case__    							=				False

 for i in range(1	,     r + 1	):
  for j in range(1	,     number + 1	):
   if j < values[i - 1]:
    snake_case__    							=				subset[i - 1][j]
   else:
    snake_case__    							=				subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

 return subset[r][number] != 0





def 							a__			(  _UpperCAmelCase	)    ->  bool:

 '''simple docstring'''






 return abundant(_UpperCAmelCase	) and not semi_perfect(_UpperCAmelCase	)


if __name__ == "__main__":
   import doctest

   doctest.testmod(verbose=True)
   for number in (6_9, 7_0, 7_1):
      print(f'''{number} is {'' if weird(number) else 'not '}weird.''')

