





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


a__:      Tuple									=		logging.get_logger(__name__)

a__:      Any									=		{
    'facebook/s2t-wav2vec2-large-en-de': (
        'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json'
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}




class     SCREAMING_SNAKE_CASE__ (						UpperCamelCase__      ):
 __SCREAMING_SNAKE_CASE							       =	'''speech_to_text_2'''
 __SCREAMING_SNAKE_CASE							       =	['''past_key_values''']
 __SCREAMING_SNAKE_CASE							       =	{'''num_attention_heads''': '''decoder_attention_heads''', '''hidden_size''': '''d_model'''}



 def __init__(							self,__lowerCamelCase=1_0000,__lowerCamelCase=6,__lowerCamelCase=2048,__lowerCamelCase=4,__lowerCamelCase=0.0,__lowerCamelCase=True,__lowerCamelCase="relu",__lowerCamelCase=256,__lowerCamelCase=0.1,__lowerCamelCase=0.0,__lowerCamelCase=0.0,__lowerCamelCase=0.02,__lowerCamelCase=2,__lowerCamelCase=True,__lowerCamelCase=1,__lowerCamelCase=0,__lowerCamelCase=2,__lowerCamelCase=1024,**__lowerCamelCase,):
        A__											=						vocab_size
        A__											=						d_model
        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__											=						decoder_layerdrop
        A__											=						use_cache
        A__											=						decoder_layers
        A__											=						scale_embedding  # scale factor will be sqrt(d_model) if True
        A__											=						max_target_positions

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












import argparse

import torch

from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
from transformers.utils import logging


logging.set_verbosity_info()


def 	UpperCamelCase__(       UpperCamelCase__			:       Any ,     UpperCamelCase__			:       int ,     UpperCamelCase__			:       int  )->int:
       # Initialise PyTorch model
       A__											=						BertConfig.from_json_file(UpperCamelCase__  )
       print(f"Building PyTorch model from configuration: {config}"  )
       A__											=						BertForPreTraining(UpperCamelCase__  )

       # Load weights from tf checkpoint
       load_tf_weights_in_bert(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__:      str									=		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(
           '--bert_config_file',
           default=None,
           type=str,
           required=True,
           help=(
               'The config json file corresponding to the pre-trained BERT 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.'
       )
       a__:      Any									=		parser.parse_args()
       convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)





