
"""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  (    SCREAMING_SNAKE_CASE:					List[str]     ,  SCREAMING_SNAKE_CASE:					Optional[Any]     ,  SCREAMING_SNAKE_CASE:					List[str]						):






							"""simple docstring"""



							if openai_config_file == "":
														_lowerCAmelCase  	=			OpenAIGPTConfig()
							else:
														_lowerCAmelCase  	=			OpenAIGPTConfig.from_json_file(SCREAMING_SNAKE_CASE						)
							_lowerCAmelCase  	=			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  	=			pytorch_dump_folder_path + '/' + WEIGHTS_NAME
							_lowerCAmelCase  	=			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__":
	_snake_case          =						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.'''
	    ),
	)
	_snake_case          =						parser.parse_args()
	convert_openai_checkpoint_to_pytorch(
	    args.openai_checkpoint_folder_path, args.openai_config_file, args.pytorch_dump_folder_path
	)








"""simple docstring"""



def 	__snake_case  (    SCREAMING_SNAKE_CASE:					list[int]						):






							"""simple docstring"""



							_lowerCAmelCase  	=			[]
							if len(SCREAMING_SNAKE_CASE						) == 1:
														return [nums.copy()]
							for _ in range(len(SCREAMING_SNAKE_CASE						)						):
														_lowerCAmelCase  	=			nums.pop(0						)
														_lowerCAmelCase  	=			permute(SCREAMING_SNAKE_CASE						)
														for perm in permutations:
																					perm.append(SCREAMING_SNAKE_CASE						)
														result.extend(SCREAMING_SNAKE_CASE						)
														nums.append(SCREAMING_SNAKE_CASE						)
							return result






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					Any						):






							"""simple docstring"""



							def backtrack(SCREAMING_SNAKE_CASE:					Tuple						):
														if start == len(SCREAMING_SNAKE_CASE						) - 1:
																					output.append(nums[:]						)
														else:
																					for i in range(SCREAMING_SNAKE_CASE     ,  len(SCREAMING_SNAKE_CASE						)						):
																												_lowerCAmelCase	,		_lowerCAmelCase  	=			nums[i], nums[start]
																												backtrack(start + 1						)
																												_lowerCAmelCase	,		_lowerCAmelCase  	=			nums[i], nums[start]  # backtrack

							_lowerCAmelCase  	=			[]
							backtrack(0						)
							return output


if __name__ == "__main__":
	import doctest

	# use res to print the data in permute2 function
	_snake_case          =						permutea([1, 2, 3])
	print(res)
	doctest.testmod()






