



'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


snake_case_			:     Union[str, Any]  	=  logging.get_logger(__name__)

snake_case_			:     Dict  	=  {
    'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json',
}






class 							lowercase__     (							_a       ):
	lowercase__      =      """mgp-str"""





	def __init__(			self :    str			,lowerCamelCase__ :    Optional[int]=[32, 128]			,lowerCamelCase__ :    Dict=4			,lowerCamelCase__ :    List[Any]=3			,lowerCamelCase__ :    Dict=27			,lowerCamelCase__ :    Any=38			,lowerCamelCase__ :    Optional[Any]=50257			,lowerCamelCase__ :    Any=30522			,lowerCamelCase__ :    Dict=768			,lowerCamelCase__ :    List[Any]=12			,lowerCamelCase__ :    List[Any]=12			,lowerCamelCase__ :    Dict=4.0			,lowerCamelCase__ :    int=True			,lowerCamelCase__ :    Optional[int]=False			,lowerCamelCase__ :    Any=1E-5			,lowerCamelCase__ :    List[Any]=0.0			,lowerCamelCase__ :    Any=0.0			,lowerCamelCase__ :    int=0.0			,lowerCamelCase__ :    List[str]=False			,lowerCamelCase__ :    Optional[int]=0.0_2			,**lowerCamelCase__ :    Union[str, Any]			,):







							'''simple docstring'''
							super().__init__(**snake_case_			)

							_UpperCamelCase :		Optional[int]			    =       image_size
							_UpperCamelCase :		List[Any]			    =       patch_size
							_UpperCamelCase :		Union[str, Any]			    =       num_channels
							_UpperCamelCase :		Tuple			    =       max_token_length
							_UpperCamelCase :		List[str]			    =       num_character_labels
							_UpperCamelCase :		Union[str, Any]			    =       num_bpe_labels
							_UpperCamelCase :		int			    =       num_wordpiece_labels
							_UpperCamelCase :		str			    =       hidden_size
							_UpperCamelCase :		Dict			    =       num_hidden_layers
							_UpperCamelCase :		Dict			    =       num_attention_heads
							_UpperCamelCase :		str			    =       mlp_ratio
							_UpperCamelCase :		Union[str, Any]			    =       distilled
							_UpperCamelCase :		str			    =       layer_norm_eps
							_UpperCamelCase :		Optional[Any]			    =       drop_rate
							_UpperCamelCase :		Optional[int]			    =       qkv_bias
							_UpperCamelCase :		List[Any]			    =       attn_drop_rate
							_UpperCamelCase :		Any			    =       drop_path_rate
							_UpperCamelCase :		str			    =       output_aa_attentions
							_UpperCamelCase :		Union[str, Any]			    =       initializer_range





'''simple docstring'''
import argparse

import torch

from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert
from transformers.utils import logging


logging.set_verbosity_info()






def A__   (					UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_							):
						# Initialise PyTorch model
						_UpperCamelCase :		Any			    =       LxmertConfig.from_json_file(UpperCAmelCase_							)
						print(f'Building PyTorch model from configuration: {config}'							)
						_UpperCamelCase :		int			    =       LxmertForPreTraining(UpperCAmelCase_							)

						# Load weights from tf checkpoint
						load_tf_weights_in_lxmert(UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_							)

						# Save pytorch-model
						print(f'Save PyTorch model to {pytorch_dump_path}'							)
						torch.save(model.state_dict()  ,  UpperCAmelCase_							)


if __name__ == "__main__":
					snake_case_			:     int  	=  argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
					)
					parser.add_argument(
					    '--config_file',
					    default=None,
					    type=str,
					    required=True,
					    help='The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.',
					)
					parser.add_argument(
					    '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
					)
					snake_case_			:     List[str]  	=  parser.parse_args()
					convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)


