



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     __a			(  SCREAMING_SNAKE_CASE					):
	SCREAMING_SNAKE_CASE  	=							"wavlm"



	def __init__(    self				:     Union[str, Any]					,						snake_case_				:     Tuple=32					,						snake_case_				:     List[str]=7_68					,						snake_case_				:     int=12					,						snake_case_				:     Dict=12					,						snake_case_				:     Dict=30_72					,						snake_case_				:     List[Any]="gelu"					,						snake_case_				:     Tuple=0.1					,						snake_case_				:     str=0.1					,						snake_case_				:     Dict=0.1					,						snake_case_				:     str=0.0					,						snake_case_				:     int=0.1					,						snake_case_				:     List[str]=0.1					,						snake_case_				:     List[Any]=0.0_2					,						snake_case_				:     Any=1e-5					,						snake_case_				:     List[Any]="group"					,						snake_case_				:     int="gelu"					,						snake_case_				:     int=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)					,						snake_case_				:     Optional[Any]=(5, 2, 2, 2, 2, 2, 2)					,						snake_case_				:     Dict=(10, 3, 3, 3, 3, 2, 2)					,						snake_case_				:     Any=False					,						snake_case_				:     Any=1_28					,						snake_case_				:     Dict=16					,						snake_case_				:     Union[str, Any]=3_20					,						snake_case_				:     str=8_00					,						snake_case_				:     Any=False					,						snake_case_				:     str=True					,						snake_case_				:     Union[str, Any]=0.0_5					,						snake_case_				:     int=10					,						snake_case_				:     Union[str, Any]=2					,						snake_case_				:     str=0.0					,						snake_case_				:     List[Any]=10					,						snake_case_				:     Union[str, Any]=3_20					,						snake_case_				:     List[str]=2					,						snake_case_				:     Dict=0.1					,						snake_case_				:     Union[str, Any]=1_00					,						snake_case_				:     List[str]=2_56					,						snake_case_				:     Tuple=2_56					,						snake_case_				:     List[str]=0.1					,						snake_case_				:     int="mean"					,						snake_case_				:     int=False					,						snake_case_				:     Dict=False					,						snake_case_				:     List[str]=2_56					,						snake_case_				:     Union[str, Any]=(5_12, 5_12, 5_12, 5_12, 15_00)					,						snake_case_				:     Any=(5, 3, 3, 1, 1)					,						snake_case_				:     int=(1, 2, 3, 1, 1)					,						snake_case_				:     Dict=5_12					,						snake_case_				:     Union[str, Any]=80					,						snake_case_				:     Optional[int]=0					,						snake_case_				:     str=1					,						snake_case_				:     Tuple=2					,						snake_case_				:     Dict=False					,						snake_case_				:     Union[str, Any]=3					,						snake_case_				:     Union[str, Any]=2					,						snake_case_				:     Tuple=3					,						snake_case_				:     Optional[Any]=None					,						**snake_case_				:     Optional[int]					,						)->				int:
						super().__init__(**snake_case_					,						pad_token_id=snake_case_					,						bos_token_id=snake_case_					,						eos_token_id=snake_case_)
						__lowerCAmelCase						 =hidden_size
						__lowerCAmelCase						 =feat_extract_norm
						__lowerCAmelCase						 =feat_extract_activation
						__lowerCAmelCase						 =list(snake_case_)
						__lowerCAmelCase						 =list(snake_case_)
						__lowerCAmelCase						 =list(snake_case_)
						__lowerCAmelCase						 =conv_bias
						__lowerCAmelCase						 =num_buckets
						__lowerCAmelCase						 =max_bucket_distance
						__lowerCAmelCase						 =num_conv_pos_embeddings
						__lowerCAmelCase						 =num_conv_pos_embedding_groups
						__lowerCAmelCase						 =len(self.conv_dim)
						__lowerCAmelCase						 =num_hidden_layers
						__lowerCAmelCase						 =intermediate_size
						__lowerCAmelCase						 =hidden_act
						__lowerCAmelCase						 =num_attention_heads
						__lowerCAmelCase						 =hidden_dropout
						__lowerCAmelCase						 =attention_dropout
						__lowerCAmelCase						 =activation_dropout
						__lowerCAmelCase						 =feat_proj_dropout
						__lowerCAmelCase						 =final_dropout
						__lowerCAmelCase						 =layerdrop
						__lowerCAmelCase						 =layer_norm_eps
						__lowerCAmelCase						 =initializer_range
						__lowerCAmelCase						 =num_ctc_classes
						__lowerCAmelCase						 =vocab_size
						__lowerCAmelCase						 =do_stable_layer_norm
						__lowerCAmelCase						 =use_weighted_layer_sum
						__lowerCAmelCase						 =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
						__lowerCAmelCase						 =apply_spec_augment
						__lowerCAmelCase						 =mask_time_prob
						__lowerCAmelCase						 =mask_time_length
						__lowerCAmelCase						 =mask_time_min_masks
						__lowerCAmelCase						 =mask_feature_prob
						__lowerCAmelCase						 =mask_feature_length

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

						# ctc loss
						__lowerCAmelCase						 =ctc_loss_reduction
						__lowerCAmelCase						 =ctc_zero_infinity

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

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

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



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









def        __lowerCAmelCase		(	__lowerCamelCase						:     int						)	->    bool:
					if number < 0:
										raise ValueError("""number must not be negative"""						)
					return number & (number - 1) == 0


if __name__ == "__main__":
				import doctest

				doctest.testmod()




