


"""simple docstring"""



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


__snake_case       =       logging.get_logger(__name__)

__snake_case       =       {
    """facebook/xglm-564M""": """https://huggingface.co/facebook/xglm-564M/resolve/main/config.json""",
    # See all XGLM models at https://huggingface.co/models?filter=xglm
}







class _lowerCAmelCase							( snake_case_      ):
   __UpperCAmelCase					:			List[str]				    =    '''xglm'''
   __UpperCAmelCase					:			Dict				    =    ['''past_key_values''']

   __UpperCAmelCase					:			Optional[int]				    =    {
       '''num_attention_heads''': '''attention_heads''',
       '''hidden_size''': '''d_model''',
       '''num_hidden_layers''': '''num_layers''',
   }







   def __init__(      self		,      UpperCamelCase__=25_6008		,      UpperCamelCase__=2048		,      UpperCamelCase__=1024		,      UpperCamelCase__=4096		,      UpperCamelCase__=24		,      UpperCamelCase__=16		,      UpperCamelCase__="gelu"		,      UpperCamelCase__=0.1		,      UpperCamelCase__=0.1		,      UpperCamelCase__=0.0		,      UpperCamelCase__=0.0		,      UpperCamelCase__=0.02		,      UpperCamelCase__=True		,      UpperCamelCase__=True		,      UpperCamelCase__=2		,      UpperCamelCase__=1		,      UpperCamelCase__=0		,      UpperCamelCase__=2		,      **UpperCamelCase__		,      )      ->						Tuple:

       '''simple docstring'''




       snake_case       : Union[str, Any]    =       vocab_size
       snake_case       : Optional[int]    =       max_position_embeddings
       snake_case       : Optional[Any]    =       d_model
       snake_case       : List[Any]    =       ffn_dim
       snake_case       : Any    =       num_layers
       snake_case       : Optional[int]    =       attention_heads
       snake_case       : Union[str, Any]    =       activation_function
       snake_case       : int    =       dropout
       snake_case       : Optional[Any]    =       attention_dropout
       snake_case       : str    =       activation_dropout
       snake_case       : List[str]    =       layerdrop
       snake_case       : Optional[Any]    =       init_std
       snake_case       : Union[str, Any]    =       scale_embedding  # scale factor will be sqrt(d_model) if True
       snake_case       : Tuple    =       use_cache

       super().__init__(
           pad_token_id=UpperCamelCase__		,      bos_token_id=UpperCamelCase__		,      eos_token_id=UpperCamelCase__		,      decoder_start_token_id=UpperCamelCase__		,      **UpperCamelCase__		,      )









"""simple docstring"""



import argparse

import torch

from ...utils import logging
from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert


logging.set_verbosity_info()







def     __lowerCAmelCase		(		lowercase    :    List[Any]		,				lowercase    :    Dict		,				lowercase    :    str					)      ->		Optional[int]:


    """simple docstring"""





    snake_case       : Tuple    =       AlbertConfig.from_json_file(lowercase					)
    print(F'Building PyTorch model from configuration: {config}'					)
    snake_case       : int    =       AlbertForPreTraining(lowercase					)

    # Load weights from tf checkpoint
    load_tf_weights_in_albert(lowercase		,				lowercase		,				lowercase					)

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


if __name__ == "__main__":
  __snake_case       =       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(
      """--albert_config_file""",
      default=None,
      type=str,
      required=True,
      help=(
          """The config json file corresponding to the pre-trained ALBERT 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."""
  )
  __snake_case       =       parser.parse_args()
  convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.albert_config_file, args.pytorch_dump_path)





