





"""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 			_a						(				lowerCAmelCase__    ):
				UpperCamelCase								=   "unispeech"






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




										'''simple docstring'''



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

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

										# ctc loss
										_UpperCamelCase      : Union[str, Any]         =   ctc_loss_reduction
										_UpperCamelCase      : Tuple         =   ctc_zero_infinity

										# pretraining loss
										_UpperCamelCase      : Any         =   replace_prob






				@property
				def     snake_case     (			self		:   List[str]							)     ->				Union[str, Any]:




										'''simple docstring'''



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










"""simple docstring"""




class 			_a						:






				def __init__(			self		:   Optional[int],			lowerCAmelCase__		:   list							)     ->				None:




										'''simple docstring'''



										_UpperCamelCase      : Optional[int]         =   set_counts
										_UpperCamelCase      : Any         =   max(lowerCAmelCase__							)
										_UpperCamelCase      : int         =   len(lowerCAmelCase__							)
										_UpperCamelCase      : int         =   [1] * num_sets
										_UpperCamelCase      : List[Any]         =   list(range(lowerCAmelCase__							)							)






				def     snake_case     (			self		:   int,			lowerCAmelCase__		:   int,			lowerCAmelCase__		:   int							)     ->				bool:




										'''simple docstring'''



										_UpperCamelCase      : Optional[Any]         =   self.get_parent(lowerCAmelCase__							)
										_UpperCamelCase      : Any         =   self.get_parent(lowerCAmelCase__							)

										if src_parent == dst_parent:
																return False

										if self.ranks[dst_parent] >= self.ranks[src_parent]:
																self.set_counts[dst_parent] += self.set_counts[src_parent]
																_UpperCamelCase      : List[Any]         =   0
																_UpperCamelCase      : str         =   dst_parent
																if self.ranks[dst_parent] == self.ranks[src_parent]:
																						self.ranks[dst_parent] += 1
																_UpperCamelCase      : Union[str, Any]         =   self.set_counts[dst_parent]
										else:
																self.set_counts[src_parent] += self.set_counts[dst_parent]
																_UpperCamelCase      : Tuple         =   0
																_UpperCamelCase      : Optional[Any]         =   src_parent
																_UpperCamelCase      : int         =   self.set_counts[src_parent]

										_UpperCamelCase      : Optional[Any]         =   max(self.max_set,			lowerCAmelCase__							)
										return True






				def     snake_case     (			self		:   Optional[Any],			lowerCAmelCase__		:   int							)     ->				int:




										'''simple docstring'''



										if self.parents[disj_set] == disj_set:
																return disj_set
										_UpperCamelCase      : Union[str, Any]         =   self.get_parent(self.parents[disj_set]							)
										return self.parents[disj_set]



