"""simple docstring"""






from ...configuration_utils import PretrainedConfig


class     UpperCAmelCase						(_UpperCAmelCase  ):



    """simple docstring"""

    _UpperCAmelCase	:List[Any]						    = "bert-generation"






    def __init__(   self    ,			_UpperCAmelCase=50358    ,			_UpperCAmelCase=1024    ,			_UpperCAmelCase=24    ,			_UpperCAmelCase=16    ,			_UpperCAmelCase=4096    ,			_UpperCAmelCase="gelu"    ,			_UpperCAmelCase=0.1    ,			_UpperCAmelCase=0.1    ,			_UpperCAmelCase=512    ,			_UpperCAmelCase=0.02    ,			_UpperCAmelCase=1e-1_2    ,			_UpperCAmelCase=0    ,			_UpperCAmelCase=2    ,			_UpperCAmelCase=1    ,			_UpperCAmelCase="absolute"    ,			_UpperCAmelCase=True    ,			**_UpperCAmelCase    ,			):
       super().__init__(pad_token_id=_UpperCAmelCase    ,			bos_token_id=_UpperCAmelCase    ,			eos_token_id=_UpperCAmelCase    ,			**_UpperCAmelCase							)

       lowercase__:   str					=      vocab_size
       lowercase__:   Optional[Any]					=      hidden_size
       lowercase__:   Union[str, Any]					=      num_hidden_layers
       lowercase__:   Dict					=      num_attention_heads
       lowercase__:   Any					=      hidden_act
       lowercase__:   Optional[Any]					=      intermediate_size
       lowercase__:   Any					=      hidden_dropout_prob
       lowercase__:   Optional[int]					=      attention_probs_dropout_prob
       lowercase__:   Optional[int]					=      max_position_embeddings
       lowercase__:   List[str]					=      initializer_range
       lowercase__:   List[str]					=      layer_norm_eps
       lowercase__:   Any					=      position_embedding_type
       lowercase__:   Optional[Any]					=      use_cache

"""simple docstring"""






import argparse

import torch

from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel
from transformers.utils import logging


logging.set_verbosity_info()



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase )  ->  List[Any]:
   # Initialise PyTorch model
   lowercase__:   Optional[Any]					=      FunnelConfig.from_json_file(__UpperCAmelCase )
   print(F"""Building PyTorch model from configuration: {config}""" )
   lowercase__:   List[Any]					=      FunnelBaseModel(__UpperCAmelCase ) if base_model else FunnelModel(__UpperCAmelCase )

   # Load weights from tf checkpoint
   load_tf_weights_in_funnel(__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			   = 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."
       )
       parser.add_argument(
           "--base_model", action="store_true", help="Whether you want just the base model (no decoder) or not."
       )
       __A			   = parser.parse_args()
       convert_tf_checkpoint_to_pytorch(
           args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.base_model
       )
