

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


UpperCAmelCase__       :   str 			=			logging.get_logger(__name__)

UpperCAmelCase__       :   List[str] 			=			{
    '''facebook/s2t-small-librispeech-asr''': (
        '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}







class 				a__				(      UpperCamelCase_				):







  """simple docstring"""




  UpperCAmelCase__					:       Tuple					="""speech_to_text"""
  UpperCAmelCase__					:       Union[str, Any]					=["""past_key_values"""]
  UpperCAmelCase__					:       Tuple					={"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}


  def __init__(	self			:       Union[str, Any] , UpperCAmelCase__			:       Optional[Any]=1_0_0_0_0 , UpperCAmelCase__			:       Optional[int]=1_2 , UpperCAmelCase__			:       int=2_0_4_8 , UpperCAmelCase__			:       str=4 , UpperCAmelCase__			:       Tuple=6 , UpperCAmelCase__			:       Dict=2_0_4_8 , UpperCAmelCase__			:       Optional[int]=4 , UpperCAmelCase__			:       Any=0.0 , UpperCAmelCase__			:       Dict=0.0 , UpperCAmelCase__			:       Optional[Any]=True , UpperCAmelCase__			:       List[Any]=True , UpperCAmelCase__			:       Tuple="relu" , UpperCAmelCase__			:       List[str]=2_5_6 , UpperCAmelCase__			:       Tuple=0.1 , UpperCAmelCase__			:       Dict=0.0 , UpperCAmelCase__			:       List[str]=0.0 , UpperCAmelCase__			:       Optional[Any]=0.02 , UpperCAmelCase__			:       Dict=2 , UpperCAmelCase__			:       Tuple=True , UpperCAmelCase__			:       int=1 , UpperCAmelCase__			:       Any=0 , UpperCAmelCase__			:       List[Any]=2 , UpperCAmelCase__			:       Optional[Any]=6_0_0_0 , UpperCAmelCase__			:       Union[str, Any]=1_0_2_4 , UpperCAmelCase__			:       List[str]=2 , UpperCAmelCase__			:       List[Any]=(5, 5) , UpperCAmelCase__			:       Union[str, Any]=1_0_2_4 , UpperCAmelCase__			:       Any=8_0 , UpperCAmelCase__			:       Any=1 , **UpperCAmelCase__			:       List[str] , )    ->List[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE       :					Dict        =      vocab_size
        SCREAMING_SNAKE_CASE       :					Optional[Any]        =      d_model
        SCREAMING_SNAKE_CASE       :					List[str]        =      encoder_ffn_dim
        SCREAMING_SNAKE_CASE       :					Optional[Any]        =      encoder_layers
        SCREAMING_SNAKE_CASE       :					Any        =      encoder_attention_heads
        SCREAMING_SNAKE_CASE       :					List[str]        =      decoder_ffn_dim
        SCREAMING_SNAKE_CASE       :					int        =      decoder_layers
        SCREAMING_SNAKE_CASE       :					Tuple        =      decoder_attention_heads
        SCREAMING_SNAKE_CASE       :					Optional[int]        =      dropout
        SCREAMING_SNAKE_CASE       :					List[Any]        =      attention_dropout
        SCREAMING_SNAKE_CASE       :					List[Any]        =      activation_dropout
        SCREAMING_SNAKE_CASE       :					List[str]        =      activation_function
        SCREAMING_SNAKE_CASE       :					List[str]        =      init_std
        SCREAMING_SNAKE_CASE       :					List[str]        =      encoder_layerdrop
        SCREAMING_SNAKE_CASE       :					Union[str, Any]        =      decoder_layerdrop
        SCREAMING_SNAKE_CASE       :					Union[str, Any]        =      use_cache
        SCREAMING_SNAKE_CASE       :					Optional[int]        =      encoder_layers
        SCREAMING_SNAKE_CASE       :					Union[str, Any]        =      scale_embedding  # scale factor will be sqrt(d_model) if True
        SCREAMING_SNAKE_CASE       :					Optional[Any]        =      max_source_positions
        SCREAMING_SNAKE_CASE       :					int        =      max_target_positions
        SCREAMING_SNAKE_CASE       :					Tuple        =      num_conv_layers
        SCREAMING_SNAKE_CASE       :					str        =      list(A_						)
        SCREAMING_SNAKE_CASE       :					int        =      conv_channels
        SCREAMING_SNAKE_CASE       :					str        =      input_feat_per_channel
        SCREAMING_SNAKE_CASE       :					Dict        =      input_channels

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

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









import argparse
import os
import re

import packaging.version


A__  :  Dict								=					'''examples/'''
A__  :  Any								=					{
    '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''),
    '''init''': (re.compile(R'''^__version__\s+=\s+"([^"]+)"\s*$''', re.MULTILINE), '''__version__ = "VERSION"\n'''),
    '''setup''': (re.compile(R'''^(\s*)version\s*=\s*"[^"]+",''', re.MULTILINE), R'''\1version="VERSION",'''),
    '''doc''': (re.compile(R'''^(\s*)release\s*=\s*"[^"]+"$''', re.MULTILINE), '''release = "VERSION"\n'''),
}
A__  :  Any								=					{
    '''init''': '''src/transformers/__init__.py''',
    '''setup''': '''setup.py''',
}
A__  :  Any								=					'''README.md'''


def 			UpperCamelCase(  __UpperCamelCase							:		int     ,__UpperCamelCase							:		List[Any]     ,__UpperCamelCase							:		List[Any] ):
		with open(__UpperCamelCase     ,'''r'''     ,encoding='''utf-8'''     ,newline='''\n''' ) as f:
				lowerCAmelCase_			:     Tuple									= f.read()
		lowerCAmelCase_					,  lowerCAmelCase_			:     Dict									= REPLACE_PATTERNS[pattern]
		lowerCAmelCase_			:     Tuple									= replace.replace('''VERSION'''     ,__UpperCamelCase )
		lowerCAmelCase_			:     Optional[int]									= re_pattern.sub(__UpperCamelCase     ,__UpperCamelCase )
		with open(__UpperCamelCase     ,'''w'''     ,encoding='''utf-8'''     ,newline='''\n''' ) as f:
				f.write(__UpperCamelCase )


def 			UpperCamelCase(  __UpperCamelCase							:		Union[str, Any] ):
		for folder, directories, fnames in os.walk(__UpperCamelCase ):
				# Removing some of the folders with non-actively maintained examples from the walk
				if "research_projects" in directories:
						directories.remove('''research_projects''' )
				if "legacy" in directories:
						directories.remove('''legacy''' )
				for fname in fnames:
						if fname.endswith('''.py''' ):
								update_version_in_file(os.path.join(__UpperCamelCase     ,__UpperCamelCase )     ,__UpperCamelCase     ,pattern='''examples''' )


def 			UpperCamelCase(  __UpperCamelCase							:		int     ,__UpperCamelCase							:		List[Any]=False ):
		for pattern, fname in REPLACE_FILES.items():
				update_version_in_file(__UpperCamelCase     ,__UpperCamelCase     ,__UpperCamelCase )
		if not patch:
				update_version_in_examples(__UpperCamelCase )


def 			UpperCamelCase(  ):
		lowerCAmelCase_			:     List[str]									= '''🤗 Transformers currently provides the following architectures'''
		lowerCAmelCase_			:     List[Any]									= '''1. Want to contribute a new model?'''
		with open(__UpperCamelCase     ,'''r'''     ,encoding='''utf-8'''     ,newline='''\n''' ) as f:
				lowerCAmelCase_			:     Union[str, Any]									= f.readlines()

		# Find the start of the list.
		lowerCAmelCase_			:     int									= 0
		while not lines[start_index].startswith(_start_prompt ):
				start_index += 1
		start_index += 1

		lowerCAmelCase_			:     str									= start_index
		# Update the lines in the model list.
		while not lines[index].startswith(_end_prompt ):
				if lines[index].startswith('''1.''' ):
						lowerCAmelCase_			:     int									= lines[index].replace(
						    '''https://huggingface.co/docs/transformers/main/model_doc'''     ,'''https://huggingface.co/docs/transformers/model_doc'''     ,)
				index += 1

		with open(__UpperCamelCase     ,'''w'''     ,encoding='''utf-8'''     ,newline='''\n''' ) as f:
				f.writelines(__UpperCamelCase )


def 			UpperCamelCase(  ):
		with open(REPLACE_FILES['''init''']     ,'''r''' ) as f:
				lowerCAmelCase_			:     Optional[Any]									= f.read()
		lowerCAmelCase_			:     Dict									= REPLACE_PATTERNS['''init'''][0].search(__UpperCamelCase ).groups()[0]
		return packaging.version.parse(__UpperCamelCase )


def 			UpperCamelCase(  __UpperCamelCase							:		Dict=False ):
		lowerCAmelCase_			:     Union[str, Any]									= get_version()
		if patch and default_version.is_devrelease:
				raise ValueError('''Can\'t create a patch version from the dev branch, checkout a released version!''' )
		if default_version.is_devrelease:
				lowerCAmelCase_			:     List[str]									= default_version.base_version
		elif patch:
				lowerCAmelCase_			:     int									= f"""{default_version.major}.{default_version.minor}.{default_version.micro + 1}"""
		else:
				lowerCAmelCase_			:     int									= f"""{default_version.major}.{default_version.minor + 1}.0"""

		# Now let's ask nicely if that's the right one.
		lowerCAmelCase_			:     Optional[Any]									= input(f"""Which version are you releasing? [{default_version}]""" )
		if len(__UpperCamelCase ) == 0:
				lowerCAmelCase_			:     List[str]									= default_version

		print(f"""Updating version to {version}.""" )
		global_version_update(__UpperCamelCase     ,patch=__UpperCamelCase )
		if not patch:
				print('''Cleaning main README, don\'t forget to run `make fix-copies`.''' )
				clean_main_ref_in_model_list()


def 			UpperCamelCase(  ):
		lowerCAmelCase_			:     Any									= get_version()
		lowerCAmelCase_			:     int									= f"""{current_version.major}.{current_version.minor + 1}.0.dev0"""
		lowerCAmelCase_			:     Optional[Any]									= current_version.base_version

		# Check with the user we got that right.
		lowerCAmelCase_			:     Optional[Any]									= input(f"""Which version are we developing now? [{dev_version}]""" )
		if len(__UpperCamelCase ) == 0:
				lowerCAmelCase_			:     int									= dev_version

		print(f"""Updating version to {version}.""" )
		global_version_update(__UpperCamelCase )
		print('''Cleaning main README, don\'t forget to run `make fix-copies`.''' )
		clean_main_ref_in_model_list()


if __name__ == "__main__":
						A__  :  Dict								=					argparse.ArgumentParser()
						parser.add_argument('''--post_release''', action='''store_true''', help='''Whether this is pre or post release.''')
						parser.add_argument('''--patch''', action='''store_true''', help='''Whether or not this is a patch release.''')
						A__  :  Optional[int]								=					parser.parse_args()
						if not args.post_release:
												pre_release_work(patch=args.patch)
						elif args.patch:
												print('''Nothing to do after a patch :-)''')
						else:
												post_release_work()





