



'''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)







'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

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


snake_case_			:     Optional[int]  	=  logging.get_logger(__name__)

snake_case_			:     List[Any]  	=  {
    'facebook/xlm-roberta-xl': 'https://huggingface.co/facebook/xlm-roberta-xl/resolve/main/config.json',
    'facebook/xlm-roberta-xxl': 'https://huggingface.co/facebook/xlm-roberta-xxl/resolve/main/config.json',
    # See all XLM-RoBERTa-XL models at https://huggingface.co/models?filter=xlm-roberta-xl
}






class 							lowercase__     (							lowercase       ):
	lowercase__      =      """xlm-roberta-xl"""





	def __init__(			self :    Optional[int]			,lowerCamelCase__ :    Optional[Any]=250880			,lowerCamelCase__ :    Tuple=2560			,lowerCamelCase__ :    Union[str, Any]=36			,lowerCamelCase__ :    List[str]=32			,lowerCamelCase__ :    Optional[Any]=10240			,lowerCamelCase__ :    Tuple="gelu"			,lowerCamelCase__ :    int=0.1			,lowerCamelCase__ :    int=0.1			,lowerCamelCase__ :    Optional[int]=514			,lowerCamelCase__ :    List[str]=1			,lowerCamelCase__ :    Dict=0.0_2			,lowerCamelCase__ :    Any=1E-05			,lowerCamelCase__ :    Union[str, Any]=1			,lowerCamelCase__ :    str=0			,lowerCamelCase__ :    Tuple=2			,lowerCamelCase__ :    Union[str, Any]="absolute"			,lowerCamelCase__ :    Optional[Any]=True			,lowerCamelCase__ :    List[str]=None			,**lowerCamelCase__ :    Dict			,):







							'''simple docstring'''
							super().__init__(pad_token_id=lowerCamelCase__			,bos_token_id=lowerCamelCase__			,eos_token_id=lowerCamelCase__			,**lowerCamelCase__			)
							_UpperCamelCase :		Optional[int]			    =       vocab_size
							_UpperCamelCase :		Optional[Any]			    =       hidden_size
							_UpperCamelCase :		str			    =       num_hidden_layers
							_UpperCamelCase :		str			    =       num_attention_heads
							_UpperCamelCase :		Any			    =       hidden_act
							_UpperCamelCase :		Dict			    =       intermediate_size
							_UpperCamelCase :		Optional[int]			    =       hidden_dropout_prob
							_UpperCamelCase :		Any			    =       attention_probs_dropout_prob
							_UpperCamelCase :		List[Any]			    =       max_position_embeddings
							_UpperCamelCase :		str			    =       type_vocab_size
							_UpperCamelCase :		Optional[Any]			    =       initializer_range
							_UpperCamelCase :		Optional[int]			    =       layer_norm_eps
							_UpperCamelCase :		Optional[int]			    =       position_embedding_type
							_UpperCamelCase :		Optional[Any]			    =       use_cache
							_UpperCamelCase :		Optional[Any]			    =       classifier_dropout






class 							lowercase__     (							lowercase       ):





	@property
	def      UpperCamelCase_  (			self :    List[Any]			):







							'''simple docstring'''
							if self.task == "multiple-choice":
													_UpperCamelCase :		Union[str, Any]			    =       {0: 'batch', 1: 'choice', 2: 'sequence'}
							else:
													_UpperCamelCase :		Optional[Any]			    =       {0: 'batch', 1: 'sequence'}
							return OrderedDict(
							    [
							        ('input_ids', dynamic_axis),
							        ('attention_mask', dynamic_axis),
							    ]			)


