
"""simple docstring"""



from typing import Callable, Optional, Union

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


a					:	str							=		logging.get_logger(__name__)

a					:	Dict							=		{
    '''microsoft/xprophetnet-large-wiki100-cased''': (
        '''https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased/resolve/main/config.json'''
    ),
}




class 		a_						( _UpperCAmelCase	):
    a      :				Optional[int]     =				'xlm-prophetnet'
    a      :				List[str]     =				['past_key_values']
    a      :				Any     =				{
        'num_attention_heads': 'num_encoder_attention_heads',
    }







    def __init__(			self			:       Optional[Any]     ,					__UpperCamelCase			:       Optional[float] = 0.1     ,					__UpperCamelCase			:       Optional[Union[str, Callable]] = "gelu"     ,					__UpperCamelCase			:       Optional[int] = 3_05_22     ,					__UpperCamelCase			:       Optional[int] = 10_24     ,					__UpperCamelCase			:       Optional[int] = 40_96     ,					__UpperCamelCase			:       Optional[int] = 12     ,					__UpperCamelCase			:       Optional[int] = 16     ,					__UpperCamelCase			:       Optional[int] = 40_96     ,					__UpperCamelCase			:       Optional[int] = 12     ,					__UpperCamelCase			:       Optional[int] = 16     ,					__UpperCamelCase			:       Optional[float] = 0.1     ,					__UpperCamelCase			:       Optional[float] = 0.1     ,					__UpperCamelCase			:       Optional[int] = 5_12     ,					__UpperCamelCase			:       Optional[float] = 0.0_2     ,					__UpperCamelCase			:       Optional[bool] = True     ,					__UpperCamelCase			:       Optional[bool] = True     ,					__UpperCamelCase			:       Optional[int] = 0     ,					__UpperCamelCase			:       Optional[int] = 2     ,					__UpperCamelCase			:       Optional[int] = 32     ,					__UpperCamelCase			:       Optional[int] = 1_28     ,					__UpperCamelCase			:       Optional[bool] = False     ,					__UpperCamelCase			:       Optional[float] = 0.0     ,					__UpperCamelCase			:       Optional[bool] = True     ,					__UpperCamelCase			:       Optional[int] = 0     ,					__UpperCamelCase			:       Optional[int] = 1     ,					__UpperCamelCase			:       Optional[int] = 2     ,					**__UpperCamelCase			:       Tuple     ,					)		->Optional[Any]:






        '''simple docstring'''






        _UpperCAmelCase          =   vocab_size
        _UpperCAmelCase          =   hidden_size
        _UpperCAmelCase          =   encoder_ffn_dim
        _UpperCAmelCase          =   num_encoder_layers
        _UpperCAmelCase          =   num_encoder_attention_heads
        _UpperCAmelCase          =   decoder_ffn_dim
        _UpperCAmelCase          =   num_decoder_layers
        _UpperCAmelCase          =   num_decoder_attention_heads
        _UpperCAmelCase          =   max_position_embeddings
        _UpperCAmelCase          =   init_std  # Normal(0, this parameter)
        _UpperCAmelCase          =   activation_function

        # parameters for xlmprophetnet
        _UpperCAmelCase          =   ngram
        _UpperCAmelCase          =   num_buckets
        _UpperCAmelCase          =   relative_max_distance
        _UpperCAmelCase          =   disable_ngram_loss
        _UpperCAmelCase          =   eps

        # 3 Types of Dropout
        _UpperCAmelCase          =   attention_dropout
        _UpperCAmelCase          =   activation_dropout
        _UpperCAmelCase          =   dropout

        _UpperCAmelCase          =   use_cache

        super().__init__(
            pad_token_id=__UpperCamelCase     ,					bos_token_id=__UpperCamelCase     ,					eos_token_id=__UpperCamelCase     ,					is_encoder_decoder=__UpperCamelCase     ,					add_cross_attention=__UpperCamelCase     ,					decoder_start_token_id=__UpperCamelCase     ,					**__UpperCamelCase     ,					)







    @property
    def      _snake_case					(			self			:       List[str]     )		->int:






        '''simple docstring'''






        return self.num_encoder_layers + self.num_decoder_layers







    @num_hidden_layers.setter
    def      _snake_case					(			self			:       Union[str, Any]     ,					__UpperCamelCase			:       str     )		->Optional[Any]:






        '''simple docstring'''






        raise NotImplementedError(
            """This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and"""
            """ `num_decoder_layers`."""     )

"""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  _UpperCamelCase	(						_A					,      _A					,      _A      )    ->  List[Any]:





    """simple docstring"""

    _UpperCAmelCase          =   LxmertConfig.from_json_file(_A      )
    print(F"""Building PyTorch model from configuration: {config}"""      )
    _UpperCAmelCase          =   LxmertForPreTraining(_A      )

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

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


if __name__ == "__main__":
 a					:	Dict							=		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.'''
 )
 a					:	Union[str, Any]							=		parser.parse_args()
 convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)