
'''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     UpperCAmelCase_	(						_SCREAMING_SNAKE_CASE					):






						'''simple docstring'''






						_lowercase						: Union[str, Any]										=  '''wavlm'''




						def __init__(   self       ,  _lowercase=32       ,  _lowercase=768       ,  _lowercase=12       ,  _lowercase=12       ,  _lowercase=3_072       ,  _lowercase="gelu"       ,  _lowercase=0.1       ,  _lowercase=0.1       ,  _lowercase=0.1       ,  _lowercase=0.0       ,  _lowercase=0.1       ,  _lowercase=0.1       ,  _lowercase=0.02       ,  _lowercase=1e-5       ,  _lowercase="group"       ,  _lowercase="gelu"       ,  _lowercase=(512, 512, 512, 512, 512, 512, 512)       ,  _lowercase=(5, 2, 2, 2, 2, 2, 2)       ,  _lowercase=(10, 3, 3, 3, 3, 2, 2)       ,  _lowercase=False       ,  _lowercase=128       ,  _lowercase=16       ,  _lowercase=320       ,  _lowercase=800       ,  _lowercase=False       ,  _lowercase=True       ,  _lowercase=0.05       ,  _lowercase=10       ,  _lowercase=2       ,  _lowercase=0.0       ,  _lowercase=10       ,  _lowercase=320       ,  _lowercase=2       ,  _lowercase=0.1       ,  _lowercase=100       ,  _lowercase=256       ,  _lowercase=256       ,  _lowercase=0.1       ,  _lowercase="mean"       ,  _lowercase=False       ,  _lowercase=False       ,  _lowercase=256       ,  _lowercase=(512, 512, 512, 512, 1_500)       ,  _lowercase=(5, 3, 3, 1, 1)       ,  _lowercase=(1, 2, 3, 1, 1)       ,  _lowercase=512       ,  _lowercase=80       ,  _lowercase=0       ,  _lowercase=1       ,  _lowercase=2       ,  _lowercase=False       ,  _lowercase=3       ,  _lowercase=2       ,  _lowercase=3       ,  _lowercase=None       ,  **_lowercase       ,  ):

												"""simple docstring"""



												super().__init__(**_lowercase       ,  pad_token_id=_lowercase       ,  bos_token_id=_lowercase       ,  eos_token_id=_lowercase )
												_lowerCAmelCase    		=					hidden_size
												_lowerCAmelCase    		=					feat_extract_norm
												_lowerCAmelCase    		=					feat_extract_activation
												_lowerCAmelCase    		=					list(_lowercase )
												_lowerCAmelCase    		=					list(_lowercase )
												_lowerCAmelCase    		=					list(_lowercase )
												_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(_lowercase )
												_lowerCAmelCase    		=					list(_lowercase )
												_lowerCAmelCase    		=					list(_lowercase )
												_lowerCAmelCase    		=					xvector_output_dim




						@property
						def    _lowercase      (   self ):

												"""simple docstring"""



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


import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
		from .tokenization_fnet import FNetTokenizer
else:
		lowercase    :   List[Any]						=			None

lowercase    :   Tuple						=			logging.get_logger(__name__)
lowercase    :   Optional[Any]						=			{'vocab_file': 'spiece.model', 'tokenizer_file': 'tokenizer.json'}

lowercase    :   str						=			{
    'vocab_file': {
        'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/spiece.model',
        'google/fnet-large': 'https://huggingface.co/google/fnet-large/resolve/main/spiece.model',
    },
    'tokenizer_file': {
        'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/tokenizer.json',
        'google/fnet-large': 'https://huggingface.co/google/fnet-large/resolve/main/tokenizer.json',
    },
}

lowercase    :   int						=			{
    'google/fnet-base': 512,
    'google/fnet-large': 512,
}

lowercase    :   str						=			'▁'




class 					lowerCamelCase__				(							__lowercase):




	'''simple docstring'''




	_A								=	VOCAB_FILES_NAMES
	_A								=	PRETRAINED_VOCAB_FILES_MAP
	_A								=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	_A								=	['input_ids', 'token_type_ids']
	_A								=	FNetTokenizer







	def __init__(   self						:Optional[int]	,  a						:Union[str, Any]=None	,  a						:Optional[int]=None	,  a						:str=False	,  a						:Tuple=True	,  a						:Optional[Any]=True	,  a						:Optional[int]="<unk>"	,  a						:List[str]="[SEP]"	,  a						:Optional[Any]="<pad>"	,  a						:int="[CLS]"	,  a						:Dict="[MASK]"	,  **a						:Optional[int]	,  )						->					List[str]:
								# Mask token behave like a normal word, i.e. include the space before it and
								# is included in the raw text, there should be a match in a non-normalized sentence.
								__UpperCamelCase      :  List[Any]       =   (
								    AddedToken(a	,  lstrip=a	,  rstrip=a	,  normalized=a		)
								    if isinstance(a	,  a		)
								    else mask_token
								)

								super().__init__(
								    a	,  tokenizer_file=a	,  do_lower_case=a	,  remove_space=a	,  keep_accents=a	,  unk_token=a	,  sep_token=a	,  pad_token=a	,  cls_token=a	,  mask_token=a	,  **a	,  )

								__UpperCamelCase      :  List[Any]       =   do_lower_case
								__UpperCamelCase      :  str       =   remove_space
								__UpperCamelCase      :  Dict       =   keep_accents
								__UpperCamelCase      :  Union[str, Any]       =   vocab_file
								__UpperCamelCase      :  List[str]       =   False if not self.vocab_file else True







	def   _lowerCamelCase							(   self						:Dict	,  a						:List[int]	,  a						:Optional[List[int]] = None		)						->					List[int]:
								__UpperCamelCase      :  List[str]       =   [self.sep_token_id]
								__UpperCamelCase      :  List[str]       =   [self.cls_token_id]
								if token_ids_a is None:
															return cls + token_ids_a + sep
								return cls + token_ids_a + sep + token_ids_a + sep







	def   _lowerCamelCase							(   self						:Union[str, Any]	,  a						:List[int]	,  a						:Optional[List[int]] = None		)						->					List[int]:
								__UpperCamelCase      :  List[Any]       =   [self.sep_token_id]
								__UpperCamelCase      :  List[Any]       =   [self.cls_token_id]

								if token_ids_a is None:
															return len(cls + token_ids_a + sep		) * [0]
								return len(cls + token_ids_a + sep		) * [0] + len(token_ids_a + sep		) * [1]







	def   _lowerCamelCase							(   self						:int	,  a						:str	,  a						:Optional[str] = None		)						->					Tuple[str]:
								if not os.path.isdir(a		):
															logger.error(f'Vocabulary path ({save_directory}) should be a directory'		)
															return
								__UpperCamelCase      :  str       =   os.path.join(
								    a	,  (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]		)

								if os.path.abspath(self.vocab_file		) != os.path.abspath(a		):
															copyfile(self.vocab_file	,  a		)

								return (out_vocab_file,)