


"""simple docstring"""







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


lowerCamelCase_   :   str									=  logging.get_logger(__name__)

lowerCamelCase_   :   str									=  {
    """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""",
    # See all PEGASUS models at https://huggingface.co/models?filter=pegasus
}






class       __A				(       _SCREAMING_SNAKE_CASE			):






 """simple docstring"""




 __lowerCAmelCase 					=  "pegasus"
 __lowerCAmelCase 					=  ["past_key_values"]
 __lowerCAmelCase 					=  {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


 def __init__(		self ,    __A=5_0265 ,    __A=1024 ,    __A=12 ,    __A=4096 ,    __A=16 ,    __A=12 ,    __A=4096 ,    __A=16 ,    __A=0.0 ,    __A=0.0 ,    __A=True ,    __A=True ,    __A="gelu" ,    __A=1024 ,    __A=0.1 ,    __A=0.0 ,    __A=0.0 ,    __A=0.02 ,    __A=0 ,    __A=False ,    __A=0 ,    __A=1 ,    __A=1 ,    **__A ,    )					->     Union[str, Any]:
     a 		=vocab_size
     a 		=max_position_embeddings
     a 		=d_model
     a 		=encoder_ffn_dim
     a 		=encoder_layers
     a 		=encoder_attention_heads
     a 		=decoder_ffn_dim
     a 		=decoder_layers
     a 		=decoder_attention_heads
     a 		=dropout
     a 		=attention_dropout
     a 		=activation_dropout
     a 		=activation_function
     a 		=init_std
     a 		=encoder_layerdrop
     a 		=decoder_layerdrop
     a 		=use_cache
     a 		=encoder_layers
     a 		=scale_embedding  # scale factor will be sqrt(d_model) if True
     super().__init__(
         pad_token_id=__A ,    eos_token_id=__A ,    is_encoder_decoder=__A ,    decoder_start_token_id=__A ,    forced_eos_token_id=__A ,    **__A ,    )


 @property
 def       SCREAMING_SNAKE_CASE							(		self						)					->     int:
     return self.encoder_attention_heads





 @property
 def       SCREAMING_SNAKE_CASE							(		self						)					->     int:
     return self.d_model
import argparse

import torch

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


logging.set_verbosity_info()






def  snake_case  (       snake_case__			:int   ,	snake_case__			:List[str]   ,	snake_case__			:Union[str, Any])						->   str:
       # Initialise PyTorch model
       _A        =  AlbertConfig.from_json_file(snake_case__)
       print(F'''Building PyTorch model from configuration: {config}''')
       _A        =  AlbertForPreTraining(snake_case__)

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

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


if __name__ == "__main__":
    _SCREAMING_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.'
    )
    _SCREAMING_SNAKE_CASE										=						parser.parse_args()
    convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.albert_config_file, args.pytorch_dump_path)




