



import functools
import operator

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


snake_case    :						str  =						logging.get_logger(__name__)

snake_case    :						Union[str, 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__  (	UpperCAmelCase__						):
					__A     :    str           =						'wavlm'







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

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

											# ctc loss
											A__	:							List[str]						    = ctc_loss_reduction
											A__	:							Optional[int]						    = ctc_zero_infinity

											# adapter
											A__	:							List[Any]						    = add_adapter
											A__	:							int						    = adapter_kernel_size
											A__	:							Optional[Any]						    = adapter_stride
											A__	:							str						    = num_adapter_layers
											A__	:							int						    = output_hidden_size or hidden_size

											# SequenceClassification-specific parameter. Feel free to ignore for other classes.
											A__	:							int						    = classifier_proj_size

											# XVector-specific parameters. Feel free to ignore for other classes.
											A__	:							Union[str, Any]						    = list(__lowerCAmelCase)
											A__	:							List[Any]						    = list(__lowerCAmelCase)
											A__	:							Union[str, Any]						    = list(__lowerCAmelCase)
											A__	:							Optional[Any]						    = xvector_output_dim







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




import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
		import ctypes
		import msvcrt  # noqa




		class 							lowerCAmelCase__  (	ctypes.Structure						):
							# _fields is a specific attr expected by ctypes
							__A     :    Optional[Any]           =						[('size', ctypes.c_int), ('visible', ctypes.c_byte)]
def 	snake_case__       (					)		->		List[Any]:







						"""simple docstring"""

						if os.name == "nt":
												A__	:							Optional[Any]						    = CursorInfo()
												A__	:							Tuple						    = ctypes.windll.kernelaa.GetStdHandle(-1_1       )
												ctypes.windll.kernelaa.GetConsoleCursorInfo(__lowercase							,     ctypes.byref(__lowercase       )       )
												A__	:							Any						    = False
												ctypes.windll.kernelaa.SetConsoleCursorInfo(__lowercase							,     ctypes.byref(__lowercase       )       )
						elif os.name == "posix":
												sys.stdout.write("\033[?25l"       )
												sys.stdout.flush()
def 	snake_case__       (					)		->		Dict:







						"""simple docstring"""

						if os.name == "nt":
												A__	:							List[str]						    = CursorInfo()
												A__	:							Optional[int]						    = ctypes.windll.kernelaa.GetStdHandle(-1_1       )
												ctypes.windll.kernelaa.GetConsoleCursorInfo(__lowercase							,     ctypes.byref(__lowercase       )       )
												A__	:							int						    = True
												ctypes.windll.kernelaa.SetConsoleCursorInfo(__lowercase							,     ctypes.byref(__lowercase       )       )
						elif os.name == "posix":
												sys.stdout.write("\033[?25h"       )
												sys.stdout.flush()




@contextmanager
def 	snake_case__       (					)		->		Optional[int]:







						"""simple docstring"""

						try:
												hide_cursor()
												yield
						finally:
												show_cursor()