
'''simple docstring'''







from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowercase    :							List[str]      =					logging.get_logger(__name__)

lowercase    :							List[Any]      =					{
    """google/mobilenet_v1_1.0_224""": """https://huggingface.co/google/mobilenet_v1_1.0_224/resolve/main/config.json""",
    """google/mobilenet_v1_0.75_192""": """https://huggingface.co/google/mobilenet_v1_0.75_192/resolve/main/config.json""",
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
}


class 						__UpperCAmelCase      (					__snake_case						):
							__lowercase      		=       """mobilenet_v1"""


							def __init__(       self    ,   lowerCAmelCase_=3    ,   lowerCAmelCase_=2_24    ,   lowerCAmelCase_=1.0    ,   lowerCAmelCase_=8    ,   lowerCAmelCase_="relu6"    ,   lowerCAmelCase_=True    ,   lowerCAmelCase_=0.999    ,   lowerCAmelCase_=0.02    ,   lowerCAmelCase_=0.001    ,   **lowerCAmelCase_    ,   ):





								"""simple docstring"""






								super().__init__(**a_  )

								if depth_multiplier <= 0:
									raise ValueError('depth_multiplier must be greater than zero.'  )

								_snake_case   						=		num_channels
								_snake_case   						=		image_size
								_snake_case   						=		depth_multiplier
								_snake_case   						=		min_depth
								_snake_case   						=		hidden_act
								_snake_case   						=		tf_padding
								_snake_case   						=		classifier_dropout_prob
								_snake_case   						=		initializer_range
								_snake_case   						=		layer_norm_eps


class 						__UpperCAmelCase      (					__snake_case						):
							__lowercase      		=       version.parse("""1.11"""						)


							@property
							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								return OrderedDict([('pixel_values', {0: 'batch'})]  )


							@property
							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								if self.task == "image-classification":
									return OrderedDict([('logits', {0: 'batch'})]  )
								else:
									return OrderedDict([('last_hidden_state', {0: 'batch'}), ('pooler_output', {0: 'batch'})]  )




							@property
							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								return 1E-4





"""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 		lowercase							(     _snake_case						:      List[Any]     ,   _snake_case						:      Tuple     ,   _snake_case						:      int     )     ->List[Any]:
	"""simple docstring"""





	if openai_config_file == "":
		__snake_case	:						Dict						=				OpenAIGPTConfig()
	else:
		__snake_case	:						int						=				OpenAIGPTConfig.from_json_file(_snake_case     )
	__snake_case	:						Tuple						=				OpenAIGPTModel(_snake_case     )

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

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


if __name__ == "__main__":
			SCREAMING_SNAKE_CASE :    Any									=				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."""
			    ),
			)
			SCREAMING_SNAKE_CASE :    Optional[int]									=				parser.parse_args()
			convert_openai_checkpoint_to_pytorch(
			    args.openai_checkpoint_folder_path, args.openai_config_file, args.pytorch_dump_folder_path
			)





