



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


lowerCAmelCase__       =  logging.get_logger(__name__)

lowerCAmelCase__       =  {
    """speechbrain/m-ctc-t-large""": """https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json""",
    # See all M-CTC-T models at https://huggingface.co/models?filter=mctct
}

class       snake_case__(UpperCAmelCase__			):

					"""simple docstring"""






					lowercase_								=		"""mctct"""







					def __init__(							self					:	Union[str, Any]      ,   SCREAMING_SNAKE_CASE					:	str=8_065      ,   SCREAMING_SNAKE_CASE					:	Optional[Any]=1_536      ,   SCREAMING_SNAKE_CASE					:	str=36      ,   SCREAMING_SNAKE_CASE					:	List[str]=6_144      ,   SCREAMING_SNAKE_CASE					:	Optional[Any]=4      ,   SCREAMING_SNAKE_CASE					:	Optional[Any]=384      ,   SCREAMING_SNAKE_CASE					:	Tuple=920      ,   SCREAMING_SNAKE_CASE					:	Any=1E-5      ,   SCREAMING_SNAKE_CASE					:	Optional[Any]=0.3      ,   SCREAMING_SNAKE_CASE					:	Any="relu"      ,   SCREAMING_SNAKE_CASE					:	Any=0.02      ,   SCREAMING_SNAKE_CASE					:	Dict=0.3      ,   SCREAMING_SNAKE_CASE					:	int=0.3      ,   SCREAMING_SNAKE_CASE					:	Union[str, Any]=1      ,   SCREAMING_SNAKE_CASE					:	Union[str, Any]=0      ,   SCREAMING_SNAKE_CASE					:	Union[str, Any]=2      ,   SCREAMING_SNAKE_CASE					:	Union[str, Any]=1      ,   SCREAMING_SNAKE_CASE					:	List[str]=0.3      ,   SCREAMING_SNAKE_CASE					:	Optional[int]=1      ,   SCREAMING_SNAKE_CASE					:	Dict=(7,)      ,   SCREAMING_SNAKE_CASE					:	Union[str, Any]=(3,)      ,   SCREAMING_SNAKE_CASE					:	Tuple=80      ,   SCREAMING_SNAKE_CASE					:	Union[str, Any]=1      ,   SCREAMING_SNAKE_CASE					:	Any=None      ,   SCREAMING_SNAKE_CASE					:	Any="sum"      ,   SCREAMING_SNAKE_CASE					:	List[Any]=False      ,   **SCREAMING_SNAKE_CASE					:	Any      ,   ):
									super().__init__(**lowercase_      ,   pad_token_id=lowercase_      ,   bos_token_id=lowercase_      ,   eos_token_id=lowercase_     )
									lowercase__     :    str													=     vocab_size
									lowercase__     :    Optional[int]													=     hidden_size
									lowercase__     :    int													=     num_hidden_layers
									lowercase__     :    List[Any]													=     intermediate_size
									lowercase__     :    List[str]													=     num_attention_heads
									lowercase__     :    Any													=     attention_head_dim
									lowercase__     :    int													=     max_position_embeddings
									lowercase__     :    List[str]													=     layer_norm_eps
									lowercase__     :    Union[str, Any]													=     layerdrop
									lowercase__     :    str													=     hidden_act
									lowercase__     :    List[Any]													=     initializer_range
									lowercase__     :    Optional[int]													=     hidden_dropout_prob
									lowercase__     :    Tuple													=     attention_probs_dropout_prob
									lowercase__     :    Tuple													=     pad_token_id
									lowercase__     :    Tuple													=     bos_token_id
									lowercase__     :    int													=     eos_token_id
									lowercase__     :    Optional[Any]													=     conv_glu_dim
									lowercase__     :    List[str]													=     conv_dropout
									lowercase__     :    Optional[Any]													=     num_conv_layers
									lowercase__     :    Tuple													=     input_feat_per_channel
									lowercase__     :    Optional[int]													=     input_channels
									lowercase__     :    List[str]													=     conv_channels
									lowercase__     :    Union[str, Any]													=     ctc_loss_reduction
									lowercase__     :    str													=     ctc_zero_infinity

									# prevents config testing fail with exporting to json
									lowercase__     :    Optional[Any]													=     list(lowercase_     )
									lowercase__     :    Tuple													=     list(lowercase_     )

									if len(self.conv_kernel     ) != self.num_conv_layers:
													raise ValueError(
													    "Configuration for convolutional module is incorrect. "
													    "It is required that `len(config.conv_kernel)` == `config.num_conv_layers` "
													    f"""but is `len(config.conv_kernel) = {len(self.conv_kernel     )}`, """
													    f"""`config.num_conv_layers = {self.num_conv_layers}`."""     )












"""simple docstring"""






import argparse

import torch

from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()



def 					_A			(__a    ,				__a    ,				__a							) ->       Dict:
    """simple docstring"""






    if gpta_config_file == "":
        SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		GPTaConfig()
    else:
        SCREAMING_SNAKE_CASE_      :  Tuple    						=		GPTaConfig.from_json_file(__a							)
    SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		GPTaModel(__a							)

    # Load weights from numpy
    load_tf_weights_in_gpta(__a    ,				__a    ,				__a							)

    # Save pytorch-model
    SCREAMING_SNAKE_CASE_      :  List[str]    						=		pytorch_dump_folder_path + '''/''' + WEIGHTS_NAME
    SCREAMING_SNAKE_CASE_      :  List[Any]    						=		pytorch_dump_folder_path + '''/''' + CONFIG_NAME
    print(f'Save PyTorch model to {pytorch_weights_dump_path}'							)
    torch.save(model.state_dict()    ,				__a							)
    print(f'Save configuration file to {pytorch_config_dump_path}'							)
    with open(__a    ,				'''w'''    ,				encoding='''utf-8'''							) as f:
        f.write(config.to_json_string()							)


if __name__ == "__main__":
  UpperCAmelCase_   : str   			= argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      """--gpt2_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
  )
  parser.add_argument(
      """--pytorch_dump_folder_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
  )
  parser.add_argument(
      """--gpt2_config_file""",
      default="""""",
      type=str,
      help=(
          """An optional config json file corresponding to the pre-trained OpenAI model. \n"""
          """This specifies the model architecture."""
      ),
  )
  UpperCAmelCase_   : Union[str, Any]   			= parser.parse_args()
  convert_gpta_checkpoint_to_pytorch(args.gpta_checkpoint_path, args.gpta_config_file, args.pytorch_dump_folder_path)


