





def 			lowerCAmelCase_			(				UpperCamelCase_	)  ->		float:
       return -num if num < 0 else num




def 			lowerCAmelCase_			(				UpperCamelCase_	)  ->		int:







       if len(UpperCamelCase_	) == 0:
              raise ValueError("abs_min() arg is an empty sequence"	)
       UpperCamelCase_ 							=	x[0]
       for i in x:
              if abs_val(UpperCamelCase_	) < abs_val(UpperCamelCase_	):
                     UpperCamelCase_ 							=	i
       return j




def 			lowerCAmelCase_			(				UpperCamelCase_	)  ->		int:







       if len(UpperCamelCase_	) == 0:
              raise ValueError("abs_max() arg is an empty sequence"	)
       UpperCamelCase_ 							=	x[0]
       for i in x:
              if abs(UpperCamelCase_	) > abs(UpperCamelCase_	):
                     UpperCamelCase_ 							=	i
       return j




def 			lowerCAmelCase_			(				UpperCamelCase_	)  ->		int:







       if len(UpperCamelCase_	) == 0:
              raise ValueError("abs_max_sort() arg is an empty sequence"	)
       return sorted(UpperCamelCase_       ,		key=UpperCamelCase_	)[-1]




def 			lowerCAmelCase_			(				)  ->		str:
       assert abs_val(0	) == 0
       assert abs_val(34	) == 34
       assert abs_val(-100000000000	) == 100000000000

       UpperCamelCase_ 							=	[-3, -1, 2, -11]
       assert abs_max(UpperCamelCase_	) == -11
       assert abs_max_sort(UpperCamelCase_	) == -11
       assert abs_min(UpperCamelCase_	) == -1


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     test_abs_val()
     print(abs_val(-3_4))  # --> 34









"""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 							lowerCAmelCase			(   UpperCamelCase_:				Dict  ,			UpperCamelCase_:				Dict  ,			UpperCamelCase_:				Any       )							->				Tuple:







  '''simple docstring'''







  _a					      =						{"small": (512, 8, 24), "medium": (1024, 8, 36), "large": (1536, 16, 48)}
  _a      ,						_a      ,						_a					      =						MODELS[model_size]  # set model hyperparameters
  _a					      =						ImageGPTConfig(n_embd=UpperCamelCase_  ,			n_layer=UpperCamelCase_  ,			n_head=UpperCamelCase_       )
  _a					      =						ImageGPTForCausalLM(UpperCamelCase_       )

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

  # Save pytorch-model
  _a					      =						pytorch_dump_folder_path + "/" + WEIGHTS_NAME
  _a					      =						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__":
     UpperCamelCase											=     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."""
     )
     UpperCamelCase											=     parser.parse_args()
     convert_imagegpt_checkpoint_to_pytorch(
         args.imagegpt_checkpoint_path, args.model_size, args.pytorch_dump_folder_path
     )


