



"""simple docstring"""






import functools
import operator

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


__UpperCAmelCase      =    logging.get_logger(__name__)

__UpperCAmelCase      =    {
    '''microsoft/unispeech-large-1500h-cv''': (
        '''https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json'''
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}






class 	__snake_case	(     _lowercase):
  snake_case__    :       List[str]        =						"unispeech"




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






         """simple docstring"""






         super().__init__(**__lowerCAmelCase						, pad_token_id=__lowerCAmelCase						, bos_token_id=__lowerCAmelCase						, eos_token_id=__lowerCAmelCase		)
         _lowerCamelCase						:    Union[str, Any]         =			hidden_size
         _lowerCamelCase						:    Tuple         =			feat_extract_norm
         _lowerCamelCase						:    Any         =			feat_extract_activation
         _lowerCamelCase						:    Any         =			list(__lowerCAmelCase		)
         _lowerCamelCase						:    str         =			list(__lowerCAmelCase		)
         _lowerCamelCase						:    Optional[int]         =			list(__lowerCAmelCase		)
         _lowerCamelCase						:    Optional[Any]         =			conv_bias
         _lowerCamelCase						:    Tuple         =			num_conv_pos_embeddings
         _lowerCamelCase						:    Optional[int]         =			num_conv_pos_embedding_groups
         _lowerCamelCase						:    List[Any]         =			len(self.conv_dim		)
         _lowerCamelCase						:    Union[str, Any]         =			num_hidden_layers
         _lowerCamelCase						:    Any         =			intermediate_size
         _lowerCamelCase						:    Optional[int]         =			hidden_act
         _lowerCamelCase						:    List[str]         =			num_attention_heads
         _lowerCamelCase						:    List[Any]         =			hidden_dropout
         _lowerCamelCase						:    int         =			attention_dropout
         _lowerCamelCase						:    Optional[Any]         =			activation_dropout
         _lowerCamelCase						:    Any         =			feat_proj_dropout
         _lowerCamelCase						:    List[Any]         =			final_dropout
         _lowerCamelCase						:    Optional[int]         =			layerdrop
         _lowerCamelCase						:    Dict         =			layer_norm_eps
         _lowerCamelCase						:    int         =			initializer_range
         _lowerCamelCase						:    Optional[int]         =			num_ctc_classes
         _lowerCamelCase						:    int         =			vocab_size
         _lowerCamelCase						:    Dict         =			do_stable_layer_norm
         _lowerCamelCase						:    Union[str, Any]         =			use_weighted_layer_sum
         _lowerCamelCase						:    str         =			classifier_proj_size

         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[str]         =			apply_spec_augment
         _lowerCamelCase						:    int         =			mask_time_prob
         _lowerCamelCase						:    Union[str, Any]         =			mask_time_length
         _lowerCamelCase						:    Union[str, Any]         =			mask_time_min_masks
         _lowerCamelCase						:    Union[str, Any]         =			mask_feature_prob
         _lowerCamelCase						:    Tuple         =			mask_feature_length
         _lowerCamelCase						:    Dict         =			mask_feature_min_masks

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

         # ctc loss
         _lowerCamelCase						:    Optional[Any]         =			ctc_loss_reduction
         _lowerCamelCase						:    Optional[Any]         =			ctc_zero_infinity

         # pretraining loss
         _lowerCamelCase						:    Optional[int]         =			replace_prob




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






         """simple docstring"""






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







"""simple docstring"""






from torch import nn






class 	__snake_case	(     nn.Module):




  def __init__(			self					:						Optional[Any]						, __lowerCAmelCase					:						Dict						, __lowerCAmelCase					:						str		):






         """simple docstring"""






         super().__init__()
         _lowerCamelCase						:    List[str]         =			class_size
         _lowerCamelCase						:    List[str]         =			embed_size
         # self.mlp1 = nn.Linear(embed_size, embed_size)
         # self.mlp2 = (nn.Linear(embed_size, class_size))
         _lowerCamelCase						:    Optional[int]         =			nn.Linear(__lowerCAmelCase						, __lowerCAmelCase		)




  def 						SCREAMING_SNAKE_CASE    (			self					:						List[Any]						, __lowerCAmelCase					:						Tuple		):






         """simple docstring"""






         _lowerCamelCase						:    Optional[Any]         =			self.mlp(__lowerCAmelCase		)
         return logits


