
import functools
import operator

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


lowercase  : str						   =							logging.get_logger(__name__)

lowercase  : 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 __snake_case		(				lowerCAmelCase					):
    _a		:						str=    "unispeech"
    def __init__(  self		,snake_case=32		,snake_case=768		,snake_case=12		,snake_case=12		,snake_case=3072		,snake_case="gelu"		,snake_case=0.1		,snake_case=0.1		,snake_case=0.1		,snake_case=0.0		,snake_case=0.0		,snake_case=0.1		,snake_case=0.1		,snake_case=0.02		,snake_case=1e-5		,snake_case="group"		,snake_case="gelu"		,snake_case=(512, 512, 512, 512, 512, 512, 512)		,snake_case=(5, 2, 2, 2, 2, 2, 2)		,snake_case=(10, 3, 3, 3, 3, 2, 2)		,snake_case=False		,snake_case=128		,snake_case=16		,snake_case=False		,snake_case=True		,snake_case=0.05		,snake_case=10		,snake_case=2		,snake_case=0.0		,snake_case=10		,snake_case=0		,snake_case=320		,snake_case=2		,snake_case=0.1		,snake_case=100		,snake_case=256		,snake_case=256		,snake_case=0.1		,snake_case="mean"		,snake_case=False		,snake_case=False		,snake_case=256		,snake_case=80		,snake_case=0		,snake_case=1		,snake_case=2		,snake_case=0.5		,**snake_case		,):



           '''simple docstring'''







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

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

           # ctc loss
           lowercase							:					str	     =				ctc_loss_reduction
           lowercase							:					List[str]	     =				ctc_zero_infinity

           # pretraining loss
           lowercase							:					Optional[Any]	     =				replace_prob
    @property
    def 				_SCREAMING_SNAKE_CASE	(  self				):



           '''simple docstring'''







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


from bisect import bisect
from itertools import accumulate







def 						_snake_case(  SCREAMING_SNAKE_CASE__ ,     SCREAMING_SNAKE_CASE__ ,     SCREAMING_SNAKE_CASE__ ,     SCREAMING_SNAKE_CASE__    )			->   Optional[int]:
       lowercase							:					Dict	     =				sorted(zip(SCREAMING_SNAKE_CASE__ ,     SCREAMING_SNAKE_CASE__    ) ,     key=lambda SCREAMING_SNAKE_CASE__    : x[0] / x[1] ,     reverse=SCREAMING_SNAKE_CASE__    )
       lowercase     ,      lowercase							:					Optional[Any]	     =				[i[0] for i in r], [i[1] for i in r]
       lowercase							:					Any	     =				list(accumulate(SCREAMING_SNAKE_CASE__    )    )
       lowercase							:					int	     =				bisect(SCREAMING_SNAKE_CASE__ ,     SCREAMING_SNAKE_CASE__    )
       return (
           0
           if k == 0
           else sum(vl[:k]    ) + (w - acc[k - 1]) * (vl[k]) / (wt[k])
           if k != n
           else sum(vl[:k]    )
       )


if __name__ == "__main__":
  import doctest

  doctest.testmod()
