


"""simple docstring"""






import functools
import operator

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


_lowerCAmelCase							:    Optional[Any]					   =	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 							A_      (       _a ):
  lowerCAmelCase__      			=	'unispeech-sat'


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







     '''simple docstring'''







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

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

     # ctc loss
     _lowerCamelCase   :				Tuple							=     ctc_loss_reduction
     _lowerCamelCase   :				List[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   :				Any							=     list(__lowerCAmelCase    )
     _lowerCamelCase   :				Any							=     list(__lowerCAmelCase    )
     _lowerCamelCase   :				List[str]							=     list(__lowerCAmelCase    )
     _lowerCamelCase   :				Union[str, Any]							=     xvector_output_dim






  @property
  def 							_lowercase					(			self:						Optional[int]    ):







     '''simple docstring'''







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

"""simple docstring"""

import importlib
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional, Union

import torch

from ..utils import BaseOutput


SCREAMING_SNAKE_CASE_            =    '''scheduler_config.json'''
class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				List[Any]				   =						1
      __SCREAMING_SNAKE_CASE :				Dict				   =						2
      __SCREAMING_SNAKE_CASE :				List[Any]				   =						3
      __SCREAMING_SNAKE_CASE :				Any				   =						4
      __SCREAMING_SNAKE_CASE :				Any				   =						5
      __SCREAMING_SNAKE_CASE :				Union[str, Any]				   =						6
      __SCREAMING_SNAKE_CASE :				str				   =						7
      __SCREAMING_SNAKE_CASE :				Any				   =						8
      __SCREAMING_SNAKE_CASE :				Tuple				   =						9
      __SCREAMING_SNAKE_CASE :				int				   =						1_0
      __SCREAMING_SNAKE_CASE :				Union[str, Any]				   =						1_1
      __SCREAMING_SNAKE_CASE :				Union[str, Any]				   =						1_2
      __SCREAMING_SNAKE_CASE :				Dict				   =						1_3
      __SCREAMING_SNAKE_CASE :				Optional[Any]				   =						1_4

@dataclass
class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				torch.FloatTensor

class   _UpperCAmelCase				:
      __SCREAMING_SNAKE_CASE :				str				   =						SCHEDULER_CONFIG_NAME
      __SCREAMING_SNAKE_CASE :				Dict				   =						[]
      __SCREAMING_SNAKE_CASE :				Union[str, Any]				   =						True




      @classmethod
      def      a_   (				cls ,							lowercase_ = None ,							lowercase_ = None ,							lowercase_=False ,							**lowercase_ ,							)    ->       List[Any]:
          UpperCAmelCase      ,				UpperCAmelCase      ,				UpperCAmelCase          =       cls.load_config(
              pretrained_model_name_or_path=lowercase_ ,							subfolder=lowercase_ ,							return_unused_kwargs=lowercase_ ,							return_commit_hash=lowercase_ ,							**lowercase_ ,							)
          return cls.from_config(lowercase_ ,							return_unused_kwargs=lowercase_ ,							**lowercase_				)




      def      a_   (				self ,							lowercase_ ,							lowercase_ = False ,							**lowercase_				)    ->       str:
          self.save_config(save_directory=lowercase_ ,							push_to_hub=lowercase_ ,							**lowercase_				)




      @property
      def      a_   (				self				)    ->       Union[str, Any]:
          return self._get_compatibles()




      @classmethod
      def      a_   (				cls				)    ->       Any:
          UpperCAmelCase          =       list(set([cls.__name__] + cls._compatibles				)				)
          UpperCAmelCase          =       importlib.import_module(__name__.split('.'				)[0]				)
          UpperCAmelCase          =       [
              getattr(lowercase_ ,							lowercase_				) for c in compatible_classes_str if hasattr(lowercase_ ,							lowercase_				)
          ]
          return compatible_classes



