



'''simple docstring'''





from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCAmelCase      						=	logging.get_logger(__name__)

_lowerCAmelCase      						=	{
    '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json''',
}






class        lowerCAmelCase_(				SCREAMING_SNAKE_CASE_     ):
  '''simple docstring'''




  __lowercase							:      List[str]				=      '''lxmert'''
  __lowercase							:      str				=      {}




  def __init__(    self  ,__UpperCAmelCase=3_0522  ,__UpperCAmelCase=768  ,__UpperCAmelCase=12  ,__UpperCAmelCase=9500  ,__UpperCAmelCase=1600  ,__UpperCAmelCase=400  ,__UpperCAmelCase=3072  ,__UpperCAmelCase="gelu"  ,__UpperCAmelCase=0.1  ,__UpperCAmelCase=0.1  ,__UpperCAmelCase=512  ,__UpperCAmelCase=2  ,__UpperCAmelCase=0.0_2  ,__UpperCAmelCase=1E-12  ,__UpperCAmelCase=9  ,__UpperCAmelCase=5  ,__UpperCAmelCase=5  ,__UpperCAmelCase=2048  ,__UpperCAmelCase=4  ,__UpperCAmelCase=6.6_7  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,**__UpperCAmelCase  ,)    ->		Any:
      lowerCAmelCase__ :  str							      =					vocab_size
      lowerCAmelCase__ :  int							      =					hidden_size
      lowerCAmelCase__ :  List[str]							      =					num_attention_heads
      lowerCAmelCase__ :  Tuple							      =					hidden_act
      lowerCAmelCase__ :  List[str]							      =					intermediate_size
      lowerCAmelCase__ :  Dict							      =					hidden_dropout_prob
      lowerCAmelCase__ :  Optional[Any]							      =					attention_probs_dropout_prob
      lowerCAmelCase__ :  Optional[int]							      =					max_position_embeddings
      lowerCAmelCase__ :  Optional[Any]							      =					type_vocab_size
      lowerCAmelCase__ :  Tuple							      =					initializer_range
      lowerCAmelCase__ :  Dict							      =					layer_norm_eps
      lowerCAmelCase__ :  Union[str, Any]							      =					num_qa_labels
      lowerCAmelCase__ :  Optional[int]							      =					num_object_labels
      lowerCAmelCase__ :  Dict							      =					num_attr_labels
      lowerCAmelCase__ :  Tuple							      =					l_layers
      lowerCAmelCase__ :  str							      =					x_layers
      lowerCAmelCase__ :  Any							      =					r_layers
      lowerCAmelCase__ :  Dict							      =					visual_feat_dim
      lowerCAmelCase__ :  Union[str, Any]							      =					visual_pos_dim
      lowerCAmelCase__ :  Union[str, Any]							      =					visual_loss_normalizer
      lowerCAmelCase__ :  Optional[Any]							      =					task_matched
      lowerCAmelCase__ :  Any							      =					task_mask_lm
      lowerCAmelCase__ :  Union[str, Any]							      =					task_obj_predict
      lowerCAmelCase__ :  List[str]							      =					task_qa
      lowerCAmelCase__ :  Any							      =					visual_obj_loss
      lowerCAmelCase__ :  Dict							      =					visual_attr_loss
      lowerCAmelCase__ :  List[str]							      =					visual_feat_loss
      lowerCAmelCase__ :  Optional[Any]							      =					{"""vision""": r_layers, """cross_encoder""": x_layers, """language""": l_layers}
      super().__init__(**__UpperCAmelCase      )









import argparse

import torch

from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
from transformers.utils import logging


logging.set_verbosity_info()


def 	UpperCamelCase__(       UpperCamelCase__			:       Any ,     UpperCamelCase__			:       int ,     UpperCamelCase__			:       int  )->int:
       # Initialise PyTorch model
       A__											=						BertConfig.from_json_file(UpperCamelCase__  )
       print(f"Building PyTorch model from configuration: {config}"  )
       A__											=						BertForPreTraining(UpperCamelCase__  )

       # Load weights from tf checkpoint
       load_tf_weights_in_bert(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

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


if __name__ == "__main__":
       a__:      str									=		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(
           '--bert_config_file',
           default=None,
           type=str,
           required=True,
           help=(
               'The config json file corresponding to the pre-trained BERT model. \n'
               'This specifies the model architecture.'
           ),
       )
       parser.add_argument(
           '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
       )
       a__:      Any									=		parser.parse_args()
       convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)





