import functools
import operator

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


UpperCamelCase__											=   logging.get_logger(__name__)

UpperCamelCase__											=   {
    "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 	A				(							UpperCAmelCase_	):
   __UpperCAmelCase					:					List[str]    =     'unispeech-sat'


   def __init__(self	:		List[str]			,    __UpperCAmelCase	:		Tuple=3_2			,    __UpperCAmelCase	:		Union[str, Any]=7_6_8			,    __UpperCAmelCase	:		Union[str, Any]=1_2			,    __UpperCAmelCase	:		List[str]=1_2			,    __UpperCAmelCase	:		Tuple=3_0_7_2			,    __UpperCAmelCase	:		Any="gelu"			,    __UpperCAmelCase	:		Union[str, Any]=0.1			,    __UpperCAmelCase	:		List[Any]=0.1			,    __UpperCAmelCase	:		Tuple=0.1			,    __UpperCAmelCase	:		List[Any]=0.0			,    __UpperCAmelCase	:		Union[str, Any]=0.0			,    __UpperCAmelCase	:		Union[str, Any]=0.1			,    __UpperCAmelCase	:		Dict=0.1			,    __UpperCAmelCase	:		Optional[Any]=0.02			,    __UpperCAmelCase	:		Union[str, Any]=1E-5			,    __UpperCAmelCase	:		str="group"			,    __UpperCAmelCase	:		Dict="gelu"			,    __UpperCAmelCase	:		str=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)			,    __UpperCAmelCase	:		int=(5, 2, 2, 2, 2, 2, 2)			,    __UpperCAmelCase	:		List[str]=(1_0, 3, 3, 3, 3, 2, 2)			,    __UpperCAmelCase	:		List[str]=False			,    __UpperCAmelCase	:		Tuple=1_2_8			,    __UpperCAmelCase	:		str=1_6			,    __UpperCAmelCase	:		Tuple=False			,    __UpperCAmelCase	:		List[str]=True			,    __UpperCAmelCase	:		List[str]=0.05			,    __UpperCAmelCase	:		Union[str, Any]=1_0			,    __UpperCAmelCase	:		str=2			,    __UpperCAmelCase	:		int=0.0			,    __UpperCAmelCase	:		Union[str, Any]=1_0			,    __UpperCAmelCase	:		Optional[Any]=0			,    __UpperCAmelCase	:		Optional[Any]=3_2_0			,    __UpperCAmelCase	:		List[Any]=2			,    __UpperCAmelCase	:		int=0.1			,    __UpperCAmelCase	:		Union[str, Any]=1_0_0			,    __UpperCAmelCase	:		int=2_5_6			,    __UpperCAmelCase	:		Optional[int]=2_5_6			,    __UpperCAmelCase	:		List[Any]=0.1			,    __UpperCAmelCase	:		Any="mean"			,    __UpperCAmelCase	:		int=False			,    __UpperCAmelCase	:		Dict=False			,    __UpperCAmelCase	:		Tuple=2_5_6			,    __UpperCAmelCase	:		Any=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)			,    __UpperCAmelCase	:		Tuple=(5, 3, 3, 1, 1)			,    __UpperCAmelCase	:		Optional[Any]=(1, 2, 3, 1, 1)			,    __UpperCAmelCase	:		Dict=5_1_2			,    __UpperCAmelCase	:		int=0			,    __UpperCAmelCase	:		Tuple=1			,    __UpperCAmelCase	:		int=2			,    __UpperCAmelCase	:		List[Any]=5_0_4			,    **__UpperCAmelCase	:		int			,    )		->							List[Any]:
         """simple docstring"""



         super().__init__(**snake_case__			,    pad_token_id=snake_case__			,    bos_token_id=snake_case__			,    eos_token_id=snake_case__						)
         UpperCAmelCase__								=    hidden_size
         UpperCAmelCase__								=    feat_extract_norm
         UpperCAmelCase__								=    feat_extract_activation
         UpperCAmelCase__								=    list(snake_case__						)
         UpperCAmelCase__								=    list(snake_case__						)
         UpperCAmelCase__								=    list(snake_case__						)
         UpperCAmelCase__								=    conv_bias
         UpperCAmelCase__								=    num_conv_pos_embeddings
         UpperCAmelCase__								=    num_conv_pos_embedding_groups
         UpperCAmelCase__								=    len(self.conv_dim						)
         UpperCAmelCase__								=    num_hidden_layers
         UpperCAmelCase__								=    intermediate_size
         UpperCAmelCase__								=    hidden_act
         UpperCAmelCase__								=    num_attention_heads
         UpperCAmelCase__								=    hidden_dropout
         UpperCAmelCase__								=    attention_dropout
         UpperCAmelCase__								=    activation_dropout
         UpperCAmelCase__								=    feat_proj_dropout
         UpperCAmelCase__								=    final_dropout
         UpperCAmelCase__								=    layerdrop
         UpperCAmelCase__								=    layer_norm_eps
         UpperCAmelCase__								=    initializer_range
         UpperCAmelCase__								=    vocab_size
         UpperCAmelCase__								=    num_clusters
         UpperCAmelCase__								=    do_stable_layer_norm
         UpperCAmelCase__								=    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
         UpperCAmelCase__								=    apply_spec_augment
         UpperCAmelCase__								=    mask_time_prob
         UpperCAmelCase__								=    mask_time_length
         UpperCAmelCase__								=    mask_time_min_masks
         UpperCAmelCase__								=    mask_feature_prob
         UpperCAmelCase__								=    mask_feature_length
         UpperCAmelCase__								=    mask_feature_min_masks

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

         # ctc loss
         UpperCAmelCase__								=    ctc_loss_reduction
         UpperCAmelCase__								=    ctc_zero_infinity

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

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





   @property
   def      lowercase_ (self	:		Tuple						)		->							List[str]:
         """simple docstring"""



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






import argparse
import os
import re


a_     :    List[str]     		=   "src/transformers/models/auto"


# re pattern that matches mapping introductions:
#    SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict
a_     :    Optional[Any]     		=   re.compile(R"[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict")
# re pattern that matches identifiers in mappings
a_     :    Optional[int]     		=   re.compile(R"\s*\(\s*\"(\S[^\"]+)\"")


def 							__lowerCAmelCase     (							_UpperCamelCase		:	Tuple		,				_UpperCamelCase		:	bool = False						)		->				Optional[int]:
 '''simple docstring'''


 with open(_UpperCamelCase		,				'r'		,				encoding='utf-8'						) as f:
  SCREAMING_SNAKE_CASE		    =      f.read()

 SCREAMING_SNAKE_CASE		    =      content.split('\n'						)
 SCREAMING_SNAKE_CASE		    =      []
 SCREAMING_SNAKE_CASE		    =      0
 while line_idx < len(_UpperCamelCase						):
  if _re_intro_mapping.search(lines[line_idx]						) is not None:
   SCREAMING_SNAKE_CASE		    =      len(re.search(R'^(\s*)\S'		,				lines[line_idx]						).groups()[0]						) + 8
   # Start of a new mapping!
   while not lines[line_idx].startswith(' ' * indent + '('						):
    new_lines.append(lines[line_idx]						)
    line_idx += 1

   SCREAMING_SNAKE_CASE		    =      []
   while lines[line_idx].strip() != "]":
    # Blocks either fit in one line or not
    if lines[line_idx].strip() == "(":
     SCREAMING_SNAKE_CASE		    =      line_idx
     while not lines[line_idx].startswith(' ' * indent + ')'						):
      line_idx += 1
     blocks.append('\n'.join(lines[start_idx : line_idx + 1]						)						)
    else:
     blocks.append(lines[line_idx]						)
    line_idx += 1

   # Sort blocks by their identifiers
   SCREAMING_SNAKE_CASE		    =      sorted(_UpperCamelCase		,				key=lambda _UpperCamelCase						: _re_identifier.search(_UpperCamelCase						).groups()[0]						)
   new_lines += blocks
  else:
   new_lines.append(lines[line_idx]						)
   line_idx += 1

 if overwrite:
  with open(_UpperCamelCase		,				'w'		,				encoding='utf-8'						) as f:
   f.write('\n'.join(_UpperCamelCase						)						)
 elif "\n".join(_UpperCamelCase						) != content:
  return True


def 							__lowerCAmelCase     (							_UpperCamelCase		:	bool = False						)		->				Dict:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      [os.path.join(_UpperCamelCase		,				_UpperCamelCase						) for f in os.listdir(_UpperCamelCase						) if f.endswith('.py'						)]
 SCREAMING_SNAKE_CASE		    =      [sort_auto_mapping(_UpperCamelCase		,				overwrite=_UpperCamelCase						) for fname in fnames]

 if not overwrite and any(_UpperCamelCase						):
  SCREAMING_SNAKE_CASE		    =      [f for f, d in zip(_UpperCamelCase		,				_UpperCamelCase						) if d]
  raise ValueError(
      f"""The following files have auto mappings that need sorting: {', '.join(_UpperCamelCase						)}. Run `make style` to fix"""
      ' this.'						)


if __name__ == "__main__":
      a_     :    Union[str, Any]     		=   argparse.ArgumentParser()
      parser.add_argument("--check_only", action="store_true", help="Whether to only check or fix style.")
      a_     :    List[str]     		=   parser.parse_args()

      sort_all_auto_mappings(not args.check_only)

