
"""simple docstring"""


import functools
import operator

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


_lowercase				 =					logging.get_logger(__name__)

_lowercase				 =					{
    '''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_					(   _lowercase     ):



						'''simple docstring'''


						_lowerCamelCase:     Tuple   =     '''wavlm'''


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

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

							# ctc loss
							A     = ctc_loss_reduction
							A     = ctc_zero_infinity

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

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

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




						@property
						def     _SCREAMING_SNAKE_CASE   (			self  :   int   )  -> Dict:
							return functools.reduce(operator.mul	,self.conv_stride	,1   )

"""simple docstring"""


from torch import nn






def    _snake_case					(		snake_case__ :  Union[str, Any]  ):
	if act_fn in ["swish", "silu"]:
		return nn.SiLU()
	elif act_fn == "mish":
		return nn.Mish()
	elif act_fn == "gelu":
		return nn.GELU()
	else:
		raise ValueError(F'Unsupported activation function: {act_fn}'  )