import argparse
import os
import re

import packaging.version


_lowerCamelCase   :				Union[str, Any]     			=						'''examples/'''
_lowerCamelCase   :				str     			=						{
    '''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'''),
}
_lowerCamelCase   :				Any     			=						{
    '''init''': '''src/transformers/__init__.py''',
    '''setup''': '''setup.py''',
}
_lowerCamelCase   :				List[str]     			=						'''README.md'''





def 		__lowerCamelCase							(UpperCAmelCase__       :							int ,	UpperCAmelCase__       :							Union[str, Any] ,	UpperCAmelCase__       :							List[str]					):
					with open(UpperCAmelCase__ ,	"r" ,	encoding="utf-8" ,	newline="\n"					) as f:
										SCREAMING_SNAKE_CASE           =    f.read()
					SCREAMING_SNAKE_CASE     ,				SCREAMING_SNAKE_CASE           =    REPLACE_PATTERNS[pattern]
					SCREAMING_SNAKE_CASE           =    replace.replace("VERSION" ,	UpperCAmelCase__					)
					SCREAMING_SNAKE_CASE           =    re_pattern.sub(UpperCAmelCase__ ,	UpperCAmelCase__					)
					with open(UpperCAmelCase__ ,	"w" ,	encoding="utf-8" ,	newline="\n"					) as f:
										f.write(UpperCAmelCase__					)





def 		__lowerCamelCase							(UpperCAmelCase__       :							Dict					):
					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 		__lowerCamelCase							(UpperCAmelCase__       :							Any ,	UpperCAmelCase__       :							int=False					):
					for pattern, fname in REPLACE_FILES.items():
										update_version_in_file(UpperCAmelCase__ ,	UpperCAmelCase__ ,	UpperCAmelCase__					)
					if not patch:
										update_version_in_examples(UpperCAmelCase__					)





def 		__lowerCamelCase							():
					SCREAMING_SNAKE_CASE           =    "🤗 Transformers currently provides the following architectures"
					SCREAMING_SNAKE_CASE           =    "1. Want to contribute a new model?"
					with open(UpperCAmelCase__ ,	"r" ,	encoding="utf-8" ,	newline="\n"					) as f:
										SCREAMING_SNAKE_CASE           =    f.readlines()

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

					SCREAMING_SNAKE_CASE           =    start_index
					# Update the lines in the model list.
					while not lines[index].startswith(_end_prompt					):
										if lines[index].startswith("1."					):
															SCREAMING_SNAKE_CASE           =    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 		__lowerCamelCase							():
					with open(REPLACE_FILES["init"] ,	"r"					) as f:
										SCREAMING_SNAKE_CASE           =    f.read()
					SCREAMING_SNAKE_CASE           =    REPLACE_PATTERNS["init"][0].search(UpperCAmelCase__					).groups()[0]
					return packaging.version.parse(UpperCAmelCase__					)





def 		__lowerCamelCase							(UpperCAmelCase__       :							Dict=False					):
					SCREAMING_SNAKE_CASE           =    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:
										SCREAMING_SNAKE_CASE           =    default_version.base_version
					elif patch:
										SCREAMING_SNAKE_CASE           =    F"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
					else:
										SCREAMING_SNAKE_CASE           =    F"{default_version.major}.{default_version.minor + 1}.0"

					# Now let's ask nicely if that's the right one.
					SCREAMING_SNAKE_CASE           =    input(F"Which version are you releasing? [{default_version}]"					)
					if len(UpperCAmelCase__					) == 0:
										SCREAMING_SNAKE_CASE           =    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 		__lowerCamelCase							():
					SCREAMING_SNAKE_CASE           =    get_version()
					SCREAMING_SNAKE_CASE           =    F"{current_version.major}.{current_version.minor + 1}.0.dev0"
					SCREAMING_SNAKE_CASE           =    current_version.base_version

					# Check with the user we got that right.
					SCREAMING_SNAKE_CASE           =    input(F"Which version are we developing now? [{dev_version}]"					)
					if len(UpperCAmelCase__					) == 0:
										SCREAMING_SNAKE_CASE           =    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__":
							_lowerCamelCase   :				Tuple     			=						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.''')
							_lowerCamelCase   :				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()





import functools
import operator

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


_lowerCamelCase   :				int     			=						logging.get_logger(__name__)

_lowerCamelCase   :				Union[str, Any]     			=						{
    '''microsoft/unispeech-sat-base-100h-libri-ft''': (
        '''https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json'''
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}


class   lowercase      (       a       ):
							lowercase__  :    Tuple									=							"""unispeech-sat"""




							def __init__(  self				:   str		,							_UpperCamelCase				:   Tuple=32		,							_UpperCamelCase				:   Union[str, Any]=768		,							_UpperCamelCase				:   Tuple=12		,							_UpperCamelCase				:   List[str]=12		,							_UpperCamelCase				:   Tuple=3_072		,							_UpperCamelCase				:   List[str]="gelu"		,							_UpperCamelCase				:   Tuple=0.1		,							_UpperCamelCase				:   Any=0.1		,							_UpperCamelCase				:   Union[str, Any]=0.1		,							_UpperCamelCase				:   Dict=0.0		,							_UpperCamelCase				:   Tuple=0.0		,							_UpperCamelCase				:   Tuple=0.1		,							_UpperCamelCase				:   Optional[Any]=0.1		,							_UpperCamelCase				:   Tuple=0.0_2		,							_UpperCamelCase				:   Optional[int]=1e-5		,							_UpperCamelCase				:   Union[str, Any]="group"		,							_UpperCamelCase				:   Optional[int]="gelu"		,							_UpperCamelCase				:   Tuple=(512, 512, 512, 512, 512, 512, 512)		,							_UpperCamelCase				:   List[str]=(5, 2, 2, 2, 2, 2, 2)		,							_UpperCamelCase				:   Optional[int]=(10, 3, 3, 3, 3, 2, 2)		,							_UpperCamelCase				:   Optional[int]=False		,							_UpperCamelCase				:   Dict=128		,							_UpperCamelCase				:   Optional[int]=16		,							_UpperCamelCase				:   Tuple=False		,							_UpperCamelCase				:   Union[str, Any]=True		,							_UpperCamelCase				:   Optional[Any]=0.0_5		,							_UpperCamelCase				:   Union[str, Any]=10		,							_UpperCamelCase				:   Union[str, Any]=2		,							_UpperCamelCase				:   str=0.0		,							_UpperCamelCase				:   List[Any]=10		,							_UpperCamelCase				:   Optional[int]=0		,							_UpperCamelCase				:   Any=320		,							_UpperCamelCase				:   List[Any]=2		,							_UpperCamelCase				:   str=0.1		,							_UpperCamelCase				:   str=100		,							_UpperCamelCase				:   int=256		,							_UpperCamelCase				:   Optional[Any]=256		,							_UpperCamelCase				:   List[Any]=0.1		,							_UpperCamelCase				:   str="mean"		,							_UpperCamelCase				:   int=False		,							_UpperCamelCase				:   Optional[Any]=False		,							_UpperCamelCase				:   Any=256		,							_UpperCamelCase				:   str=(512, 512, 512, 512, 1_500)		,							_UpperCamelCase				:   List[Any]=(5, 3, 3, 1, 1)		,							_UpperCamelCase				:   Union[str, Any]=(1, 2, 3, 1, 1)		,							_UpperCamelCase				:   Any=512		,							_UpperCamelCase				:   str=0		,							_UpperCamelCase				:   int=1		,							_UpperCamelCase				:   Any=2		,							_UpperCamelCase				:   Optional[Any]=504		,							**_UpperCamelCase				:   str		,							)   ->			int:



												'''simple docstring'''

												super().__init__(**_UpperCamelCase		,							pad_token_id=_UpperCamelCase		,							bos_token_id=_UpperCamelCase		,							eos_token_id=_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    hidden_size
												SCREAMING_SNAKE_CASE           =    feat_extract_norm
												SCREAMING_SNAKE_CASE           =    feat_extract_activation
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    conv_bias
												SCREAMING_SNAKE_CASE           =    num_conv_pos_embeddings
												SCREAMING_SNAKE_CASE           =    num_conv_pos_embedding_groups
												SCREAMING_SNAKE_CASE           =    len(self.conv_dim )
												SCREAMING_SNAKE_CASE           =    num_hidden_layers
												SCREAMING_SNAKE_CASE           =    intermediate_size
												SCREAMING_SNAKE_CASE           =    hidden_act
												SCREAMING_SNAKE_CASE           =    num_attention_heads
												SCREAMING_SNAKE_CASE           =    hidden_dropout
												SCREAMING_SNAKE_CASE           =    attention_dropout
												SCREAMING_SNAKE_CASE           =    activation_dropout
												SCREAMING_SNAKE_CASE           =    feat_proj_dropout
												SCREAMING_SNAKE_CASE           =    final_dropout
												SCREAMING_SNAKE_CASE           =    layerdrop
												SCREAMING_SNAKE_CASE           =    layer_norm_eps
												SCREAMING_SNAKE_CASE           =    initializer_range
												SCREAMING_SNAKE_CASE           =    vocab_size
												SCREAMING_SNAKE_CASE           =    num_clusters
												SCREAMING_SNAKE_CASE           =    do_stable_layer_norm
												SCREAMING_SNAKE_CASE           =    use_weighted_layer_sum

												if (
												    (len(self.conv_stride ) != self.num_feat_extract_layers)
												    or (len(self.conv_kernel ) != self.num_feat_extract_layers)
												    or (len(self.conv_dim ) != self.num_feat_extract_layers)
												):
																	raise ValueError(
																	    "Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =="
																	    " `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ="
																	    F" {len(self.conv_dim )}`, `len(config.conv_stride) = {len(self.conv_stride )}`,"
																	    F" `len(config.conv_kernel) = {len(self.conv_kernel )}`." )

												# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
												SCREAMING_SNAKE_CASE           =    apply_spec_augment
												SCREAMING_SNAKE_CASE           =    mask_time_prob
												SCREAMING_SNAKE_CASE           =    mask_time_length
												SCREAMING_SNAKE_CASE           =    mask_time_min_masks
												SCREAMING_SNAKE_CASE           =    mask_feature_prob
												SCREAMING_SNAKE_CASE           =    mask_feature_length
												SCREAMING_SNAKE_CASE           =    mask_feature_min_masks

												# parameters for pretraining with codevector quantized representations
												SCREAMING_SNAKE_CASE           =    num_codevectors_per_group
												SCREAMING_SNAKE_CASE           =    num_codevector_groups
												SCREAMING_SNAKE_CASE           =    contrastive_logits_temperature
												SCREAMING_SNAKE_CASE           =    feat_quantizer_dropout
												SCREAMING_SNAKE_CASE           =    num_negatives
												SCREAMING_SNAKE_CASE           =    codevector_dim
												SCREAMING_SNAKE_CASE           =    proj_codevector_dim
												SCREAMING_SNAKE_CASE           =    diversity_loss_weight

												# ctc loss
												SCREAMING_SNAKE_CASE           =    ctc_loss_reduction
												SCREAMING_SNAKE_CASE           =    ctc_zero_infinity

												# SequenceClassification-specific parameter. Feel free to ignore for other classes.
												SCREAMING_SNAKE_CASE           =    classifier_proj_size

												# XVector-specific parameters. Feel free to ignore for other classes.
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    xvector_output_dim





							@property
							def 		__snake_case(  self				:   Tuple )   ->			str:



												'''simple docstring'''

												return functools.reduce(operator.mul		,							self.conv_stride		,							1 )




