
"""simple docstring"""



from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


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

a					:	List[Any]							=		{
    '''shi-labs/nat-mini-in1k-224''': '''https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json''',
    # See all Nat models at https://huggingface.co/models?filter=nat
}




class 		a_						( _UpperCAmelCase     ,						_UpperCAmelCase	):
    a      :				List[str]     =				'nat'

    a      :				List[Any]     =				{
        'num_attention_heads': 'num_heads',
        'num_hidden_layers': 'num_layers',
    }







    def __init__(			self			:       str     ,					__UpperCamelCase			:       Union[str, Any]=4     ,					__UpperCamelCase			:       Union[str, Any]=3     ,					__UpperCamelCase			:       List[str]=64     ,					__UpperCamelCase			:       Tuple=[3, 4, 6, 5]     ,					__UpperCamelCase			:       Dict=[2, 4, 8, 16]     ,					__UpperCamelCase			:       Any=7     ,					__UpperCamelCase			:       List[str]=3.0     ,					__UpperCamelCase			:       int=True     ,					__UpperCamelCase			:       Optional[Any]=0.0     ,					__UpperCamelCase			:       Tuple=0.0     ,					__UpperCamelCase			:       Any=0.1     ,					__UpperCamelCase			:       Tuple="gelu"     ,					__UpperCamelCase			:       Dict=0.0_2     ,					__UpperCamelCase			:       Any=1e-5     ,					__UpperCamelCase			:       int=0.0     ,					__UpperCamelCase			:       Optional[int]=None     ,					__UpperCamelCase			:       Union[str, Any]=None     ,					**__UpperCamelCase			:       List[Any]     ,					)		->str:






        '''simple docstring'''






        super().__init__(**__UpperCamelCase     )

        _UpperCAmelCase          =   patch_size
        _UpperCAmelCase          =   num_channels
        _UpperCAmelCase          =   embed_dim
        _UpperCAmelCase          =   depths
        _UpperCAmelCase          =   len(__UpperCamelCase     )
        _UpperCAmelCase          =   num_heads
        _UpperCAmelCase          =   kernel_size
        _UpperCAmelCase          =   mlp_ratio
        _UpperCAmelCase          =   qkv_bias
        _UpperCAmelCase          =   hidden_dropout_prob
        _UpperCAmelCase          =   attention_probs_dropout_prob
        _UpperCAmelCase          =   drop_path_rate
        _UpperCAmelCase          =   hidden_act
        _UpperCAmelCase          =   layer_norm_eps
        _UpperCAmelCase          =   initializer_range
        # we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
        # this indicates the channel dimension after the last stage of the model
        _UpperCAmelCase          =   int(embed_dim * 2 ** (len(__UpperCamelCase     ) - 1)     )
        _UpperCAmelCase          =   layer_scale_init_value
        _UpperCAmelCase          =   ["""stem"""] + [f"""stage{idx}""" for idx in range(1     ,					len(__UpperCamelCase     ) + 1     )]
        _UpperCAmelCase    ,_UpperCAmelCase          =   get_aligned_output_features_output_indices(
            out_features=__UpperCamelCase     ,					out_indices=__UpperCamelCase     ,					stage_names=self.stage_names     )

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