






import functools
import operator

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


lowerCamelCase : Optional[int]						   =       logging.get_logger(__name__)

lowerCamelCase : Tuple						   =       {
    '''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 		lowerCAmelCase     ( __a			):

					'''simple docstring'''

					_A						:			List[str]									=      '''unispeech'''



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


												"""simple docstring"""

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

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

												# ctc loss
												__lowercase      :							Tuple				=     ctc_loss_reduction
												__lowercase      :							Optional[int]				=     ctc_zero_infinity

												# pretraining loss
												__lowercase      :							str				=     replace_prob



					@property
					def       lowerCAmelCase				(  self				:	Union[str, Any]							)			->  Dict:


												"""simple docstring"""

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







from torch import nn

class 		lowerCAmelCase     ( nn.Module			):

					'''simple docstring'''

					def __init__(  self				:	Tuple		,     __a				:	int		,     __a				:	Optional[int]							)			->  Union[str, Any]:


												"""simple docstring"""

												super().__init__()
												__lowercase      :							int				=     class_size
												__lowercase      :							int				=     embed_size
												# self.mlp1 = nn.Linear(embed_size, embed_size)
												# self.mlp2 = (nn.Linear(embed_size, class_size))
												__lowercase      :							str				=     nn.Linear(__a		,     __a							)



					def       lowerCAmelCase				(  self				:	Tuple		,     __a				:	int							)			->  Tuple:


												"""simple docstring"""

												__lowercase      :							str				=     self.mlp(__a							)
												return logits