





import collections
import importlib.util
import os
import re
from pathlib import Path


_UpperCAmelCase             =							'src/transformers'


# Matches is_xxx_available()
_UpperCAmelCase             =							re.compile(R'is\_([a-z_]*)_available()')
# Catches a one-line _import_struct = {xxx}
_UpperCAmelCase             =							re.compile(R'^_import_structure\s+=\s+\{([^\}]+)\}')
# Catches a line with a key-values pattern: "bla": ["foo", "bar"]
_UpperCAmelCase             =							re.compile(R'\s+"\S*":\s+\[([^\]]*)\]')
# Catches a line if not is_foo_available
_UpperCAmelCase             =							re.compile(R'^\s*if\s+not\s+is\_[a-z_]*\_available\(\)')
# Catches a line _import_struct["bla"].append("foo")
_UpperCAmelCase             =							re.compile(R'^\s*_import_structure\["\S*"\]\.append\("(\S*)"\)')
# Catches a line _import_struct["bla"].extend(["foo", "bar"]) or _import_struct["bla"] = ["foo", "bar"]
_UpperCAmelCase             =							re.compile(R'^\s*_import_structure\[\S*\](?:\.extend\(|\s*=\s+)\[([^\]]*)\]')
# Catches a line with an object between quotes and a comma:     "MyModel",
_UpperCAmelCase             =							re.compile('^\s+"([^"]+)",')
# Catches a line with objects between brackets only:    ["foo", "bar"],
_UpperCAmelCase             =							re.compile('^\s+\[([^\]]+)\]')
# Catches a line with from foo import bar, bla, boo
_UpperCAmelCase             =							re.compile(R'\s+from\s+\S*\s+import\s+([^\(\s].*)\n')
# Catches a line with try:
_UpperCAmelCase             =							re.compile(R'^\s*try:')
# Catches a line with else:
_UpperCAmelCase             =							re.compile(R'^\s*else:')






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:List[str]   )      ->   Any:
 if _re_test_backend.search(SCREAMING_SNAKE_CASE   ) is None:
  return None
 __lowerCAmelCase					:	List[str]      =       [b[0] for b in _re_backend.findall(SCREAMING_SNAKE_CASE   )]
 backends.sort()
 return "_and_".join(SCREAMING_SNAKE_CASE   )






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:Any   )      ->   str:
 with open(SCREAMING_SNAKE_CASE   ,   """r"""   ,   encoding="""utf-8"""   ,   newline="""\n"""   ) as f:
  __lowerCAmelCase					:	int      =       f.readlines()

 __lowerCAmelCase					:	Dict      =       0
 while line_index < len(SCREAMING_SNAKE_CASE   ) and not lines[line_index].startswith("""_import_structure = {"""   ):
  line_index += 1

 # If this is a traditional init, just return.
 if line_index >= len(SCREAMING_SNAKE_CASE   ):
  return None

 # First grab the objects without a specific backend in _import_structure
 __lowerCAmelCase					:	int      =       []
 while not lines[line_index].startswith("""if TYPE_CHECKING"""   ) and find_backend(lines[line_index]   ) is None:
  __lowerCAmelCase					:	Dict      =       lines[line_index]
  # If we have everything on a single line, let's deal with it.
  if _re_one_line_import_struct.search(SCREAMING_SNAKE_CASE   ):
   __lowerCAmelCase					:	int      =       _re_one_line_import_struct.search(SCREAMING_SNAKE_CASE   ).groups()[0]
   __lowerCAmelCase					:	Optional[int]      =       re.findall("""\[([^\]]+)\]"""   ,   SCREAMING_SNAKE_CASE   )
   for imp in imports:
    objects.extend([obj[1:-1] for obj in imp.split(""", """   )]   )
   line_index += 1
   continue
  __lowerCAmelCase					:	Any      =       _re_import_struct_key_value.search(SCREAMING_SNAKE_CASE   )
  if single_line_import_search is not None:
   __lowerCAmelCase					:	str      =       [obj[1:-1] for obj in single_line_import_search.groups()[0].split(""", """   ) if len(SCREAMING_SNAKE_CASE   ) > 0]
   objects.extend(SCREAMING_SNAKE_CASE   )
  elif line.startswith(""" """ * 8 + """\""""   ):
   objects.append(line[9:-3]   )
  line_index += 1

 __lowerCAmelCase					:	List[str]      =       {"""none""": objects}
 # Let's continue with backend-specific objects in _import_structure
 while not lines[line_index].startswith("""if TYPE_CHECKING"""   ):
  # If the line is an if not is_backend_available, we grab all objects associated.
  __lowerCAmelCase					:	str      =       find_backend(lines[line_index]   )
  # Check if the backend declaration is inside a try block:
  if _re_try.search(lines[line_index - 1]   ) is None:
   __lowerCAmelCase					:	Dict      =       None

  if backend is not None:
   line_index += 1

   # Scroll until we hit the else block of try-except-else
   while _re_else.search(lines[line_index]   ) is None:
    line_index += 1

   line_index += 1

   __lowerCAmelCase					:	List[str]      =       []
   # Until we unindent, add backend objects to the list
   while len(lines[line_index]   ) <= 1 or lines[line_index].startswith(""" """ * 4   ):
    __lowerCAmelCase					:	Optional[Any]      =       lines[line_index]
    if _re_import_struct_add_one.search(SCREAMING_SNAKE_CASE   ) is not None:
     objects.append(_re_import_struct_add_one.search(SCREAMING_SNAKE_CASE   ).groups()[0]   )
    elif _re_import_struct_add_many.search(SCREAMING_SNAKE_CASE   ) is not None:
     __lowerCAmelCase					:	Optional[Any]      =       _re_import_struct_add_many.search(SCREAMING_SNAKE_CASE   ).groups()[0].split(""", """   )
     __lowerCAmelCase					:	Union[str, Any]      =       [obj[1:-1] for obj in imports if len(SCREAMING_SNAKE_CASE   ) > 0]
     objects.extend(SCREAMING_SNAKE_CASE   )
    elif _re_between_brackets.search(SCREAMING_SNAKE_CASE   ) is not None:
     __lowerCAmelCase					:	str      =       _re_between_brackets.search(SCREAMING_SNAKE_CASE   ).groups()[0].split(""", """   )
     __lowerCAmelCase					:	Any      =       [obj[1:-1] for obj in imports if len(SCREAMING_SNAKE_CASE   ) > 0]
     objects.extend(SCREAMING_SNAKE_CASE   )
    elif _re_quote_object.search(SCREAMING_SNAKE_CASE   ) is not None:
     objects.append(_re_quote_object.search(SCREAMING_SNAKE_CASE   ).groups()[0]   )
    elif line.startswith(""" """ * 8 + """\""""   ):
     objects.append(line[9:-3]   )
    elif line.startswith(""" """ * 12 + """\""""   ):
     objects.append(line[13:-3]   )
    line_index += 1

   __lowerCAmelCase					:	List[Any]      =       objects
  else:
   line_index += 1

    # At this stage we are in the TYPE_CHECKING part, first grab the objects without a specific backend
 __lowerCAmelCase					:	Tuple      =       []
 while (
     line_index < len(SCREAMING_SNAKE_CASE   )
     and find_backend(lines[line_index]   ) is None
     and not lines[line_index].startswith("""else"""   )
 ):
  __lowerCAmelCase					:	Union[str, Any]      =       lines[line_index]
  __lowerCAmelCase					:	Optional[Any]      =       _re_import.search(SCREAMING_SNAKE_CASE   )
  if single_line_import_search is not None:
   objects.extend(single_line_import_search.groups()[0].split(""", """   )   )
  elif line.startswith(""" """ * 8   ):
   objects.append(line[8:-2]   )
  line_index += 1

 __lowerCAmelCase					:	List[str]      =       {"""none""": objects}
 # Let's continue with backend-specific objects
 while line_index < len(SCREAMING_SNAKE_CASE   ):
  # If the line is an if is_backend_available, we grab all objects associated.
  __lowerCAmelCase					:	Optional[Any]      =       find_backend(lines[line_index]   )
  # Check if the backend declaration is inside a try block:
  if _re_try.search(lines[line_index - 1]   ) is None:
   __lowerCAmelCase					:	int      =       None

  if backend is not None:
   line_index += 1

   # Scroll until we hit the else block of try-except-else
   while _re_else.search(lines[line_index]   ) is None:
    line_index += 1

   line_index += 1

   __lowerCAmelCase					:	Optional[int]      =       []
   # Until we unindent, add backend objects to the list
   while len(lines[line_index]   ) <= 1 or lines[line_index].startswith(""" """ * 8   ):
    __lowerCAmelCase					:	List[Any]      =       lines[line_index]
    __lowerCAmelCase					:	Optional[Any]      =       _re_import.search(SCREAMING_SNAKE_CASE   )
    if single_line_import_search is not None:
     objects.extend(single_line_import_search.groups()[0].split(""", """   )   )
    elif line.startswith(""" """ * 12   ):
     objects.append(line[12:-2]   )
    line_index += 1

   __lowerCAmelCase					:	Union[str, Any]      =       objects
  else:
   line_index += 1

 return import_dict_objects, type_hint_objects






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:str   ,   SCREAMING_SNAKE_CASE		:str   )      ->   Union[str, Any]:

 def find_duplicates(SCREAMING_SNAKE_CASE		:Union[str, Any]   ):
  return [k for k, v in collections.Counter(SCREAMING_SNAKE_CASE   ).items() if v > 1]

 if list(import_dict_objects.keys()   ) != list(type_hint_objects.keys()   ):
  return ["Both sides of the init do not have the same backends!"]

 __lowerCAmelCase					:	Optional[Any]      =       []
 for key in import_dict_objects.keys():
  __lowerCAmelCase					:	Union[str, Any]      =       find_duplicates(import_dict_objects[key]   )
  if duplicate_imports:
   errors.append(F'''Duplicate _import_structure definitions for: {duplicate_imports}'''   )
  __lowerCAmelCase					:	int      =       find_duplicates(type_hint_objects[key]   )
  if duplicate_type_hints:
   errors.append(F'''Duplicate TYPE_CHECKING objects for: {duplicate_type_hints}'''   )

  if sorted(set(import_dict_objects[key]   )   ) != sorted(set(type_hint_objects[key]   )   ):
   __lowerCAmelCase					:	Optional[Any]      =       """base imports""" if key == """none""" else F'''{key} backend'''
   errors.append(F'''Differences for {name}:'''   )
   for a in type_hint_objects[key]:
    if a not in import_dict_objects[key]:
     errors.append(F'''  {a} in TYPE_HINT but not in _import_structure.'''   )
   for a in import_dict_objects[key]:
    if a not in type_hint_objects[key]:
     errors.append(F'''  {a} in _import_structure but not in TYPE_HINT.'''   )
 return errors






def 	_SCREAMING_SNAKE_CASE		(      )      ->   str:
 __lowerCAmelCase					:	List[Any]      =       []
 for root, _, files in os.walk(SCREAMING_SNAKE_CASE   ):
  if "__init__.py" in files:
   __lowerCAmelCase					:	List[Any]      =       os.path.join(SCREAMING_SNAKE_CASE   ,   """__init__.py"""   )
   __lowerCAmelCase					:	Tuple      =       parse_init(SCREAMING_SNAKE_CASE   )
   if objects is not None:
    __lowerCAmelCase					:	List[str]      =       analyze_results(*SCREAMING_SNAKE_CASE   )
    if len(SCREAMING_SNAKE_CASE   ) > 0:
     __lowerCAmelCase					:	Optional[Any]      =       F'''Problem in {fname}, both halves do not define the same objects.\n{errors[0]}'''
     failures.append("""\n""".join(SCREAMING_SNAKE_CASE   )   )
 if len(SCREAMING_SNAKE_CASE   ) > 0:
  raise ValueError("""\n\n""".join(SCREAMING_SNAKE_CASE   )   )






def 	_SCREAMING_SNAKE_CASE		(      )      ->   Tuple:
 __lowerCAmelCase					:	Optional[int]      =       []
 for path, directories, files in os.walk(SCREAMING_SNAKE_CASE   ):
  for folder in directories:
   # Ignore private modules
   if folder.startswith("""_"""   ):
    directories.remove(SCREAMING_SNAKE_CASE   )
    continue
   # Ignore leftovers from branches (empty folders apart from pycache)
   if len(list((Path(SCREAMING_SNAKE_CASE   ) / folder).glob("""*.py"""   )   )   ) == 0:
    continue
   __lowerCAmelCase					:	str      =       str((Path(SCREAMING_SNAKE_CASE   ) / folder).relative_to(SCREAMING_SNAKE_CASE   )   )
   __lowerCAmelCase					:	Any      =       short_path.replace(os.path.sep   ,   """."""   )
   submodules.append(SCREAMING_SNAKE_CASE   )
  for fname in files:
   if fname == "__init__.py":
    continue
   __lowerCAmelCase					:	Optional[Any]      =       str((Path(SCREAMING_SNAKE_CASE   ) / fname).relative_to(SCREAMING_SNAKE_CASE   )   )
   __lowerCAmelCase					:	str      =       short_path.replace(""".py"""   ,   """"""   ).replace(os.path.sep   ,   """."""   )
   if len(submodule.split("""."""   )   ) == 1:
    submodules.append(SCREAMING_SNAKE_CASE   )
 return submodules


_UpperCAmelCase             =							[
    'convert_pytorch_checkpoint_to_tf2',
    'modeling_flax_pytorch_utils',
]






def 	_SCREAMING_SNAKE_CASE		(      )      ->   Tuple:
 # This is to make sure the transformers module imported is the one in the repo.
 __lowerCAmelCase					:	Any      =       importlib.util.spec_from_file_location(
     """transformers"""   ,   os.path.join(SCREAMING_SNAKE_CASE   ,   """__init__.py"""   )   ,   submodule_search_locations=[PATH_TO_TRANSFORMERS]   ,   )
 __lowerCAmelCase					:	Optional[Any]      =       spec.loader.load_module()

 __lowerCAmelCase					:	Union[str, Any]      =       [
     module
     for module in get_transformers_submodules()
     if module not in IGNORE_SUBMODULES and module not in transformers._import_structure.keys()
 ]
 if len(SCREAMING_SNAKE_CASE   ) > 0:
  __lowerCAmelCase					:	Tuple      =       """\n""".join(F'''- {module}''' for module in module_not_registered   )
  raise ValueError(
      """The following submodules are not properly registered in the main init of Transformers:\n"""
      F'''{list_of_modules}\n'''
      """Make sure they appear somewhere in the keys of `_import_structure` with an empty list as value."""   )


if __name__ == "__main__":
      check_all_inits()
      check_submodules()






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        snake_case_    (		__lowercase						):
  A_      							=   'unispeech-sat'






  def __init__(							self			:					str       ,  _snake_case			:					List[Any]=32       ,  _snake_case			:					Union[str, Any]=768       ,  _snake_case			:					Tuple=12       ,  _snake_case			:					Optional[int]=12       ,  _snake_case			:					Optional[Any]=3072       ,  _snake_case			:					Tuple="gelu"       ,  _snake_case			:					int=0.1       ,  _snake_case			:					List[Any]=0.1       ,  _snake_case			:					Union[str, Any]=0.1       ,  _snake_case			:					str=0.0       ,  _snake_case			:					List[str]=0.0       ,  _snake_case			:					int=0.1       ,  _snake_case			:					Optional[Any]=0.1       ,  _snake_case			:					Optional[Any]=0.02       ,  _snake_case			:					int=1E-5       ,  _snake_case			:					Dict="group"       ,  _snake_case			:					Optional[Any]="gelu"       ,  _snake_case			:					Optional[Any]=(512, 512, 512, 512, 512, 512, 512)       ,  _snake_case			:					int=(5, 2, 2, 2, 2, 2, 2)       ,  _snake_case			:					int=(10, 3, 3, 3, 3, 2, 2)       ,  _snake_case			:					Any=False       ,  _snake_case			:					Optional[Any]=128       ,  _snake_case			:					Tuple=16       ,  _snake_case			:					str=False       ,  _snake_case			:					Dict=True       ,  _snake_case			:					Tuple=0.05       ,  _snake_case			:					str=10       ,  _snake_case			:					Tuple=2       ,  _snake_case			:					List[Any]=0.0       ,  _snake_case			:					str=10       ,  _snake_case			:					Any=0       ,  _snake_case			:					List[Any]=320       ,  _snake_case			:					Union[str, Any]=2       ,  _snake_case			:					Dict=0.1       ,  _snake_case			:					Dict=100       ,  _snake_case			:					Union[str, Any]=256       ,  _snake_case			:					int=256       ,  _snake_case			:					Union[str, Any]=0.1       ,  _snake_case			:					Optional[Any]="mean"       ,  _snake_case			:					int=False       ,  _snake_case			:					str=False       ,  _snake_case			:					str=256       ,  _snake_case			:					List[Any]=(512, 512, 512, 512, 1500)       ,  _snake_case			:					Optional[int]=(5, 3, 3, 1, 1)       ,  _snake_case			:					Tuple=(1, 2, 3, 1, 1)       ,  _snake_case			:					Dict=512       ,  _snake_case			:					Union[str, Any]=0       ,  _snake_case			:					List[str]=1       ,  _snake_case			:					Optional[Any]=2       ,  _snake_case			:					Optional[int]=504       ,  **_snake_case			:					Optional[int]       ,  )->Union[str, Any]:






   '''simple docstring'''

   super().__init__(**_snake_case       ,  pad_token_id=_snake_case       ,  bos_token_id=_snake_case       ,  eos_token_id=_snake_case      )
   __lowerCAmelCase					:	Dict      =       hidden_size
   __lowerCAmelCase					:	List[Any]      =       feat_extract_norm
   __lowerCAmelCase					:	int      =       feat_extract_activation
   __lowerCAmelCase					:	Union[str, Any]      =       list(_snake_case      )
   __lowerCAmelCase					:	str      =       list(_snake_case      )
   __lowerCAmelCase					:	Optional[Any]      =       list(_snake_case      )
   __lowerCAmelCase					:	Optional[int]      =       conv_bias
   __lowerCAmelCase					:	Dict      =       num_conv_pos_embeddings
   __lowerCAmelCase					:	List[Any]      =       num_conv_pos_embedding_groups
   __lowerCAmelCase					:	Tuple      =       len(self.conv_dim      )
   __lowerCAmelCase					:	int      =       num_hidden_layers
   __lowerCAmelCase					:	str      =       intermediate_size
   __lowerCAmelCase					:	str      =       hidden_act
   __lowerCAmelCase					:	Any      =       num_attention_heads
   __lowerCAmelCase					:	Optional[int]      =       hidden_dropout
   __lowerCAmelCase					:	str      =       attention_dropout
   __lowerCAmelCase					:	int      =       activation_dropout
   __lowerCAmelCase					:	Union[str, Any]      =       feat_proj_dropout
   __lowerCAmelCase					:	List[str]      =       final_dropout
   __lowerCAmelCase					:	Dict      =       layerdrop
   __lowerCAmelCase					:	Tuple      =       layer_norm_eps
   __lowerCAmelCase					:	Optional[Any]      =       initializer_range
   __lowerCAmelCase					:	str      =       vocab_size
   __lowerCAmelCase					:	Optional[int]      =       num_clusters
   __lowerCAmelCase					:	List[Any]      =       do_stable_layer_norm
   __lowerCAmelCase					:	Tuple      =       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
   __lowerCAmelCase					:	Dict      =       apply_spec_augment
   __lowerCAmelCase					:	List[Any]      =       mask_time_prob
   __lowerCAmelCase					:	List[str]      =       mask_time_length
   __lowerCAmelCase					:	Dict      =       mask_time_min_masks
   __lowerCAmelCase					:	Tuple      =       mask_feature_prob
   __lowerCAmelCase					:	List[str]      =       mask_feature_length
   __lowerCAmelCase					:	str      =       mask_feature_min_masks

   # parameters for pretraining with codevector quantized representations
   __lowerCAmelCase					:	Optional[int]      =       num_codevectors_per_group
   __lowerCAmelCase					:	List[Any]      =       num_codevector_groups
   __lowerCAmelCase					:	int      =       contrastive_logits_temperature
   __lowerCAmelCase					:	str      =       feat_quantizer_dropout
   __lowerCAmelCase					:	int      =       num_negatives
   __lowerCAmelCase					:	str      =       codevector_dim
   __lowerCAmelCase					:	Any      =       proj_codevector_dim
   __lowerCAmelCase					:	Any      =       diversity_loss_weight

   # ctc loss
   __lowerCAmelCase					:	Tuple      =       ctc_loss_reduction
   __lowerCAmelCase					:	Any      =       ctc_zero_infinity

   # SequenceClassification-specific parameter. Feel free to ignore for other classes.
   __lowerCAmelCase					:	Any      =       classifier_proj_size

   # XVector-specific parameters. Feel free to ignore for other classes.
   __lowerCAmelCase					:	List[str]      =       list(_snake_case      )
   __lowerCAmelCase					:	List[str]      =       list(_snake_case      )
   __lowerCAmelCase					:	Optional[int]      =       list(_snake_case      )
   __lowerCAmelCase					:	Optional[int]      =       xvector_output_dim






  @property
  def 				UpperCAmelCase__						(							self			:					Optional[Any]      )->Any:






   '''simple docstring'''

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