






import functools
import operator

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


A__           =							logging.get_logger(__name__)

A__           =							{
    '''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				):
							_UpperCAmelCase						    =     '''wavlm'''







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

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

										# ctc loss
										lowerCamelCase						:str						  =     ctc_loss_reduction
										lowerCamelCase						:Dict						  =     ctc_zero_infinity

										# adapter
										lowerCamelCase						:Dict						  =     add_adapter
										lowerCamelCase						:List[str]						  =     adapter_kernel_size
										lowerCamelCase						:Tuple						  =     adapter_stride
										lowerCamelCase						:str						  =     num_adapter_layers
										lowerCamelCase						:List[Any]						  =     output_hidden_size or hidden_size

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

										# XVector-specific parameters. Feel free to ignore for other classes.
										lowerCamelCase						:str						  =     list(__SCREAMING_SNAKE_CASE		)
										lowerCamelCase						:Any						  =     list(__SCREAMING_SNAKE_CASE		)
										lowerCamelCase						:Tuple						  =     list(__SCREAMING_SNAKE_CASE		)
										lowerCamelCase						:Dict						  =     xvector_output_dim







							@property
							def 				snake_case  (				self     :    Optional[int]		):
										return functools.reduce(operator.mul	,					self.conv_stride	,					1		)




import os
from typing import Optional

import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE
class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     ''
							_UpperCAmelCase						    =     (
							    None  # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
							)
							_UpperCAmelCase						    =     None  # compression type in fsspec. ex: "gzip"
							_UpperCAmelCase						    =     None  # extension of the filename to strip. ex: "".gz" to get file.txt from file.txt.gz







							def __init__(				self     :    str	,					__snake_case     :    str = ""	,					__snake_case     :    Optional[str] = None	,					__snake_case     :    Optional[dict] = None	,					**__snake_case     :    Dict		):
										super().__init__(self	,					**__snake_case		)
										# always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
										lowerCamelCase						:Optional[Any]						  =     fsspec.open(
										    __snake_case	,					mode='''rb'''	,					protocol=__snake_case	,					compression=self.compression	,					client_kwargs={
										        '''requote_redirect_url''': False,  # see https://github.com/huggingface/datasets/pull/5459
										        '''trust_env''': True,  # Enable reading proxy env variables.
										        **(target_options or {}).pop('''client_kwargs'''	,					{}		),  # To avoid issues if it was already passed.
										    }	,					**(target_options or {})	,					)
										lowerCamelCase						:List[str]						  =     os.path.basename(self.file.path.split('''::'''		)[0]		)
										lowerCamelCase						:Dict						  =     (
										    self.compressed_name[: self.compressed_name.rindex('''.'''		)]
										    if '''.''' in self.compressed_name
										    else self.compressed_name
										)
										lowerCamelCase						:List[str]						  =     None







							@classmethod
							def 				snake_case  (				cls     :    Any	,					__snake_case     :    Any		):
										# compressed file paths are always relative to the archive root
										return super()._strip_protocol(__snake_case		).lstrip('''/'''		)







							def 				snake_case  (				self     :    Any		):
										if self.dir_cache is None:
													lowerCamelCase						:Optional[Any]						  =     {**self.file.fs.info(self.file.path		), '''name''': self.uncompressed_name}
													lowerCamelCase						:Optional[Any]						  =     {f['''name''']: f}







							def 				snake_case  (				self     :    Union[str, Any]	,					__snake_case     :    str		):
										return self.file.open().read()







							def 				snake_case  (				self     :    Optional[int]	,					__snake_case     :    str	,					__snake_case     :    str = "rb"	,					__snake_case     :    int=None	,					__snake_case     :    Optional[int]=True	,					__snake_case     :    str=None	,					**__snake_case     :    str	,					):
										lowerCamelCase						:List[str]						  =     self._strip_protocol(__snake_case		)
										if mode != "rb":
													raise ValueError(F"Tried to read with mode {mode} on file {self.file.path} opened with mode 'rb'"		)
										return self.file.open()


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     'bz2'
							_UpperCAmelCase						    =     'bz2'
							_UpperCAmelCase						    =     '.bz2'


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     'gzip'
							_UpperCAmelCase						    =     'gzip'
							_UpperCAmelCase						    =     '.gz'


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     'lz4'
							_UpperCAmelCase						    =     'lz4'
							_UpperCAmelCase						    =     '.lz4'


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     'xz'
							_UpperCAmelCase						    =     'xz'
							_UpperCAmelCase						    =     '.xz'


class   _lowerCAmelCase		(     __SCREAMING_SNAKE_CASE				):
							_UpperCAmelCase						    =     'zstd'
							_UpperCAmelCase						    =     'zstd'
							_UpperCAmelCase						    =     '.zst'







							def __init__(				self     :    str	,					__snake_case     :    str	,					__snake_case     :    str = "rb"	,					__snake_case     :    Optional[str] = None	,					__snake_case     :    Optional[dict] = None	,					__snake_case     :    int = DEFAULT_BLOCK_SIZE	,					**__snake_case     :    int	,					):
										super().__init__(
										    fo=__snake_case	,					mode=__snake_case	,					target_protocol=__snake_case	,					target_options=__snake_case	,					block_size=__snake_case	,					**__snake_case	,					)
										# We need to wrap the zstd decompressor to avoid this error in fsspec==2021.7.0 and zstandard==0.15.2:
										#
										# File "/Users/user/.virtualenvs/hf-datasets/lib/python3.7/site-packages/fsspec/core.py", line 145, in open
										#     out.close = close
										# AttributeError: 'zstd.ZstdDecompressionReader' object attribute 'close' is read-only
										#
										# see https://github.com/intake/filesystem_spec/issues/725
										lowerCamelCase						:Tuple						  =     self.file.__enter__
										class   _lowerCAmelCase		:







																	def __init__(				self     :    Dict	,					__snake_case     :    Tuple		):
																				lowerCamelCase						:Optional[int]						  =     file_







																	def __enter__(				self     :    Optional[int]		):
																				self._file.__enter__()
																				return self







																	def __exit__(				self     :    str	,					*__snake_case     :    Optional[Any]	,					**__snake_case     :    List[Any]		):
																				self._file.__exit__(*__snake_case	,					**__snake_case		)







																	def __iter__(				self     :    Optional[Any]		):
																				return iter(self._file		)







																	def 				snake_case  (				self     :    List[Any]		):
																				return next(self._file		)







																	def __getattr__(				self     :    Any	,					__snake_case     :    str		):
																				return getattr(self._file	,					__snake_case		)

										def fixed_enter(*__snake_case     :    Optional[int]	,					**__snake_case     :    str		):
													return WrappedFile(_enter(*__snake_case	,					**__snake_case		)		)

										lowerCamelCase						:Dict						  =     fixed_enter



