




"""simple docstring"""

import functools
import operator

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


a         =      logging.get_logger(__name__)

a         =      {
    "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_	(					__lowerCAmelCase							):



	'''simple docstring'''
	UpperCAmelCase   :					Any				  =     """unispeech-sat"""

	def __init__(			self	:	str   ,							_UpperCAmelCase	:	Any=32   ,							_UpperCAmelCase	:	int=768   ,							_UpperCAmelCase	:	str=12   ,							_UpperCAmelCase	:	int=12   ,							_UpperCAmelCase	:	List[Any]=3_072   ,							_UpperCAmelCase	:	Optional[Any]="gelu"   ,							_UpperCAmelCase	:	List[Any]=0.1   ,							_UpperCAmelCase	:	List[str]=0.1   ,							_UpperCAmelCase	:	List[str]=0.1   ,							_UpperCAmelCase	:	List[Any]=0.0   ,							_UpperCAmelCase	:	int=0.0   ,							_UpperCAmelCase	:	Union[str, Any]=0.1   ,							_UpperCAmelCase	:	List[str]=0.1   ,							_UpperCAmelCase	:	List[Any]=0.02   ,							_UpperCAmelCase	:	Optional[Any]=1E-5   ,							_UpperCAmelCase	:	int="group"   ,							_UpperCAmelCase	:	Any="gelu"   ,							_UpperCAmelCase	:	Any=(512, 512, 512, 512, 512, 512, 512)   ,							_UpperCAmelCase	:	str=(5, 2, 2, 2, 2, 2, 2)   ,							_UpperCAmelCase	:	Tuple=(10, 3, 3, 3, 3, 2, 2)   ,							_UpperCAmelCase	:	Optional[int]=False   ,							_UpperCAmelCase	:	Tuple=128   ,							_UpperCAmelCase	:	Optional[int]=16   ,							_UpperCAmelCase	:	List[Any]=False   ,							_UpperCAmelCase	:	List[str]=True   ,							_UpperCAmelCase	:	str=0.05   ,							_UpperCAmelCase	:	Optional[Any]=10   ,							_UpperCAmelCase	:	Dict=2   ,							_UpperCAmelCase	:	str=0.0   ,							_UpperCAmelCase	:	Any=10   ,							_UpperCAmelCase	:	str=0   ,							_UpperCAmelCase	:	Union[str, Any]=320   ,							_UpperCAmelCase	:	List[Any]=2   ,							_UpperCAmelCase	:	str=0.1   ,							_UpperCAmelCase	:	Dict=100   ,							_UpperCAmelCase	:	Tuple=256   ,							_UpperCAmelCase	:	Any=256   ,							_UpperCAmelCase	:	Tuple=0.1   ,							_UpperCAmelCase	:	Optional[int]="mean"   ,							_UpperCAmelCase	:	List[Any]=False   ,							_UpperCAmelCase	:	Union[str, Any]=False   ,							_UpperCAmelCase	:	Any=256   ,							_UpperCAmelCase	:	List[Any]=(512, 512, 512, 512, 1_500)   ,							_UpperCAmelCase	:	Optional[int]=(5, 3, 3, 1, 1)   ,							_UpperCAmelCase	:	List[Any]=(1, 2, 3, 1, 1)   ,							_UpperCAmelCase	:	List[Any]=512   ,							_UpperCAmelCase	:	List[str]=0   ,							_UpperCAmelCase	:	List[str]=1   ,							_UpperCAmelCase	:	List[Any]=2   ,							_UpperCAmelCase	:	Optional[Any]=504   ,							**_UpperCAmelCase	:	Dict   ,							):
							super().__init__(**_A   ,							pad_token_id=_A   ,							bos_token_id=_A   ,							eos_token_id=_A		)
							_A        =       hidden_size
							_A        =       feat_extract_norm
							_A        =       feat_extract_activation
							_A        =       list(_A		)
							_A        =       list(_A		)
							_A        =       list(_A		)
							_A        =       conv_bias
							_A        =       num_conv_pos_embeddings
							_A        =       num_conv_pos_embedding_groups
							_A        =       len(self.conv_dim		)
							_A        =       num_hidden_layers
							_A        =       intermediate_size
							_A        =       hidden_act
							_A        =       num_attention_heads
							_A        =       hidden_dropout
							_A        =       attention_dropout
							_A        =       activation_dropout
							_A        =       feat_proj_dropout
							_A        =       final_dropout
							_A        =       layerdrop
							_A        =       layer_norm_eps
							_A        =       initializer_range
							_A        =       vocab_size
							_A        =       num_clusters
							_A        =       do_stable_layer_norm
							_A        =       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
							_A        =       apply_spec_augment
							_A        =       mask_time_prob
							_A        =       mask_time_length
							_A        =       mask_time_min_masks
							_A        =       mask_feature_prob
							_A        =       mask_feature_length
							_A        =       mask_feature_min_masks

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

							# ctc loss
							_A        =       ctc_loss_reduction
							_A        =       ctc_zero_infinity

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

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



	@property
	def       lowerCAmelCase_							(			self	:	Any		):
							return functools.reduce(operator.mul   ,							self.conv_stride   ,							1		)







"""simple docstring"""

import argparse
from collections import defaultdict

import yaml


a         =      '''docs/source/en/_toctree.yml'''






def 						_snake_case					( _snake_case							: List[Any]							)   -> Optional[Any]:






      '''simple docstring'''


      _A        =       defaultdict(_snake_case							)
      _A        =       []
      _A        =       []
      for doc in doc_list:
            if "local" in doc:
                  counts[doc["local"]] += 1

            if doc["title"].lower() == "overview":
                  overview_doc.append({'local': doc['local'], 'title': doc['title']}							)
            else:
                  new_doc_list.append(_snake_case							)

      _A        =       new_doc_list
      _A        =       [key for key, value in counts.items() if value > 1]

      _A        =       []
      for duplicate_key in duplicates:
            _A        =       list({doc['title'] for doc in doc_list if doc['local'] == duplicate_key}							)
            if len(_snake_case							) > 1:
                  raise ValueError(
                      F'''{duplicate_key} is present several times in the documentation table of content at '''
                      '`docs/source/en/_toctree.yml` with different *Title* values. Choose one of those and remove the '
                      'others.'							)
            # Only add this once
            new_doc.append({'local': duplicate_key, 'title': titles[0]}							)

      # Add none duplicate-keys
      new_doc.extend([doc for doc in doc_list if 'local' not in counts or counts[doc['local']] == 1]							)
      _A        =       sorted(_snake_case    ,  key=lambda _snake_case							: s["title"].lower()							)

      # "overview" gets special treatment and is always first
      if len(_snake_case							) > 1:
            raise ValueError('{doc_list} has two \'overview\' docs which is not allowed.'							)

      overview_doc.extend(_snake_case							)

      # Sort
      return overview_doc






def 						_snake_case					( _snake_case							: Tuple=False							)   -> List[Any]:






      '''simple docstring'''


      with open(_snake_case    ,  encoding='utf-8'							) as f:
            _A        =       yaml.safe_load(f.read()							)

      # Get to the API doc
      _A        =       0
      while content[api_idx]["title"] != "API":
            api_idx += 1
      _A        =       content[api_idx]['sections']

      # Then to the model doc
      _A        =       0
      while api_doc[scheduler_idx]["title"] != "Schedulers":
            scheduler_idx += 1

      _A        =       api_doc[scheduler_idx]['sections']
      _A        =       clean_doc_toc(_snake_case							)

      _A        =       False
      if new_scheduler_doc != scheduler_doc:
            _A        =       True
            if overwrite:
                  _A        =       new_scheduler_doc

      if diff:
            if overwrite:
                  _A        =       api_doc
                  with open(_snake_case    ,  'w'    ,  encoding='utf-8'							) as f:
                        f.write(yaml.dump(_snake_case    ,  allow_unicode=_snake_case							)							)
            else:
                  raise ValueError(
                      'The model doc part of the table of content is not properly sorted, run `make style` to fix this.'							)






def 						_snake_case					( _snake_case							: str=False							)   -> Union[str, Any]:






      '''simple docstring'''


      with open(_snake_case    ,  encoding='utf-8'							) as f:
            _A        =       yaml.safe_load(f.read()							)

      # Get to the API doc
      _A        =       0
      while content[api_idx]["title"] != "API":
            api_idx += 1
      _A        =       content[api_idx]['sections']

      # Then to the model doc
      _A        =       0
      while api_doc[pipeline_idx]["title"] != "Pipelines":
            pipeline_idx += 1

      _A        =       False
      _A        =       api_doc[pipeline_idx]['sections']
      _A        =       []

      # sort sub pipeline docs
      for pipeline_doc in pipeline_docs:
            if "section" in pipeline_doc:
                  _A        =       pipeline_doc['section']
                  _A        =       clean_doc_toc(_snake_case							)
                  if overwrite:
                        _A        =       new_sub_pipeline_doc
            new_pipeline_docs.append(_snake_case							)

      # sort overall pipeline doc
      _A        =       clean_doc_toc(_snake_case							)

      if new_pipeline_docs != pipeline_docs:
            _A        =       True
            if overwrite:
                  _A        =       new_pipeline_docs

      if diff:
            if overwrite:
                  _A        =       api_doc
                  with open(_snake_case    ,  'w'    ,  encoding='utf-8'							) as f:
                        f.write(yaml.dump(_snake_case    ,  allow_unicode=_snake_case							)							)
            else:
                  raise ValueError(
                      'The model doc part of the table of content is not properly sorted, run `make style` to fix this.'							)


if __name__ == "__main__":
       a         =      argparse.ArgumentParser()
       parser.add_argument('''--fix_and_overwrite''', action='''store_true''', help='''Whether to fix inconsistencies.''')
       a         =      parser.parse_args()

       check_scheduler_doc(args.fix_and_overwrite)
       check_pipeline_doc(args.fix_and_overwrite)

