


import functools
import operator

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


SCREAMING_SNAKE_CASE       :		Optional[Any]         =  logging.get_logger(__name__)

SCREAMING_SNAKE_CASE       :		List[Any]         =  {
    "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      UpperCamelCase					(		lowercase__     ):


   '''simple docstring'''







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

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

        # ctc loss
        lowercase_       :Tuple     =       ctc_loss_reduction
        lowercase_       :Dict     =       ctc_zero_infinity

        # pretraining loss
        lowercase_       :Union[str, Any]     =       replace_prob




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





def     UpperCamelCase    (      _a       ,		_a		)					->							int:
     '''simple docstring'''





     while a != 0:
          lowercase_    ,      lowercase_       :Union[str, Any]     =       b % a, a
     return b




def     UpperCamelCase    (      _a       ,		_a		)					->							int:
     '''simple docstring'''





     if gcd(_a       ,		_a		) != 1:
          lowercase_       :Union[str, Any]     =       f"mod inverse of {a!r} and {m!r} does not exist"
          raise ValueError(_a		)
     lowercase_    ,      lowercase_    ,      lowercase_       :Any     =       1, 0, a
     lowercase_    ,      lowercase_    ,      lowercase_       :List[str]     =       0, 1, m
     while va != 0:
          lowercase_       :Tuple     =       ua // va
          lowercase_    ,      lowercase_    ,      lowercase_    ,      lowercase_    ,      lowercase_    ,      lowercase_       :Optional[int]     =       (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
     return ua % m

