

'''simple docstring'''



import functools
import operator

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


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

UpperCAmelCase :       Optional[Any]			   =     {
    'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json',
    # See all WavLM models at https://huggingface.co/models?filter=wavlm
}







class 						lowerCAmelCase__   (      a					):



 """simple docstring"""



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

      # parameters for pretraining with codevector quantized representations
      __SCREAMING_SNAKE_CASE     =      num_codevectors_per_group
      __SCREAMING_SNAKE_CASE     =      num_codevector_groups
      __SCREAMING_SNAKE_CASE     =      contrastive_logits_temperature
      __SCREAMING_SNAKE_CASE     =      num_negatives
      __SCREAMING_SNAKE_CASE     =      codevector_dim
      __SCREAMING_SNAKE_CASE     =      proj_codevector_dim
      __SCREAMING_SNAKE_CASE     =      diversity_loss_weight

      # ctc loss
      __SCREAMING_SNAKE_CASE     =      ctc_loss_reduction
      __SCREAMING_SNAKE_CASE     =      ctc_zero_infinity

      # adapter
      __SCREAMING_SNAKE_CASE     =      add_adapter
      __SCREAMING_SNAKE_CASE     =      adapter_kernel_size
      __SCREAMING_SNAKE_CASE     =      adapter_stride
      __SCREAMING_SNAKE_CASE     =      num_adapter_layers
      __SCREAMING_SNAKE_CASE     =      output_hidden_size or hidden_size

      # SequenceClassification-specific parameter. Feel free to ignore for other classes.
      __SCREAMING_SNAKE_CASE     =      classifier_proj_size

      # XVector-specific parameters. Feel free to ignore for other classes.
      __SCREAMING_SNAKE_CASE     =      list(__SCREAMING_SNAKE_CASE			)
      __SCREAMING_SNAKE_CASE     =      list(__SCREAMING_SNAKE_CASE			)
      __SCREAMING_SNAKE_CASE     =      list(__SCREAMING_SNAKE_CASE			)
      __SCREAMING_SNAKE_CASE     =      xvector_output_dim


 @property
 def       UpperCAmelCase__		(		self					:       Tuple			)  -> List[Any]:


      """simple docstring"""




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









'''simple docstring'''



class 						lowerCAmelCase__   :



 """simple docstring"""



 def __init__(		self					:       List[Any]					,							__SCREAMING_SNAKE_CASE					:       int			)  -> List[Any]:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE     =      n
      __SCREAMING_SNAKE_CASE     =      [None] * self.n
      __SCREAMING_SNAKE_CASE     =      0  # index of the first element
      __SCREAMING_SNAKE_CASE     =      0
      __SCREAMING_SNAKE_CASE     =      0
 def __len__(		self					:       Tuple			)  -> int:


      """simple docstring"""




      return self.size
 def       UpperCAmelCase__		(		self					:       Optional[Any]			)  -> bool:


      """simple docstring"""




      return self.size == 0
 def       UpperCAmelCase__		(		self					:       Any			)  -> int:


      """simple docstring"""




      return False if self.is_empty() else self.array[self.front]
 def       UpperCAmelCase__		(		self					:       Dict					,							__SCREAMING_SNAKE_CASE					:       Union[str, Any]			)  -> Dict:


      """simple docstring"""




      if self.size >= self.n:
           raise Exception("""QUEUE IS FULL"""			)

      __SCREAMING_SNAKE_CASE     =      data
      __SCREAMING_SNAKE_CASE     =      (self.rear + 1) % self.n
      self.size += 1
      return self


 def       UpperCAmelCase__		(		self					:       List[str]			)  -> Optional[Any]:


      """simple docstring"""




      if self.size == 0:
           raise Exception("""UNDERFLOW"""			)

      __SCREAMING_SNAKE_CASE     =      self.array[self.front]
      __SCREAMING_SNAKE_CASE     =      None
      __SCREAMING_SNAKE_CASE     =      (self.front + 1) % self.n
      self.size -= 1
      return temp






