





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


a__:      str									=		logging.get_logger(__name__)

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




class     SCREAMING_SNAKE_CASE__ (						UpperCamelCase__      ):
 __SCREAMING_SNAKE_CASE							       =	'''lxmert'''
 __SCREAMING_SNAKE_CASE							       =	{}



 def __init__(							self,__lowerCamelCase=3_0522,__lowerCamelCase=768,__lowerCamelCase=12,__lowerCamelCase=9500,__lowerCamelCase=1600,__lowerCamelCase=400,__lowerCamelCase=3072,__lowerCamelCase="gelu",__lowerCamelCase=0.1,__lowerCamelCase=0.1,__lowerCamelCase=512,__lowerCamelCase=2,__lowerCamelCase=0.02,__lowerCamelCase=1E-12,__lowerCamelCase=9,__lowerCamelCase=5,__lowerCamelCase=5,__lowerCamelCase=2048,__lowerCamelCase=4,__lowerCamelCase=6.67,__lowerCamelCase=True,__lowerCamelCase=True,__lowerCamelCase=True,__lowerCamelCase=True,__lowerCamelCase=True,__lowerCamelCase=True,__lowerCamelCase=True,**__lowerCamelCase,):
        A__											=						vocab_size
        A__											=						hidden_size
        A__											=						num_attention_heads
        A__											=						hidden_act
        A__											=						intermediate_size
        A__											=						hidden_dropout_prob
        A__											=						attention_probs_dropout_prob
        A__											=						max_position_embeddings
        A__											=						type_vocab_size
        A__											=						initializer_range
        A__											=						layer_norm_eps
        A__											=						num_qa_labels
        A__											=						num_object_labels
        A__											=						num_attr_labels
        A__											=						l_layers
        A__											=						x_layers
        A__											=						r_layers
        A__											=						visual_feat_dim
        A__											=						visual_pos_dim
        A__											=						visual_loss_normalizer
        A__											=						task_matched
        A__											=						task_mask_lm
        A__											=						task_obj_predict
        A__											=						task_qa
        A__											=						visual_obj_loss
        A__											=						visual_attr_loss
        A__											=						visual_feat_loss
        A__											=						{'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
        super().__init__(**__lowerCamelCase )












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)





