





import functools
import operator

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


_lowerCAmelCase								=  logging.get_logger(__name__)

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

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

         # ctc loss
         A_  :					int         =						ctc_loss_reduction
         A_  :					Any         =						ctc_zero_infinity

         # adapter
         A_  :					Any         =						add_adapter
         A_  :					Optional[int]         =						adapter_kernel_size
         A_  :					Tuple         =						adapter_stride
         A_  :					int         =						num_adapter_layers
         A_  :					Tuple         =						output_hidden_size or hidden_size

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

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






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














"""simple docstring"""
import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


snake_case : List[Any]     		=		{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

snake_case : List[Any]     		=		{
    """vocab_file""": {
        """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt""",
    },
    """tokenizer_file""": {
        """unc-nlp/lxmert-base-uncased""": (
            """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json"""
        ),
    },
}

snake_case : Optional[int]     		=		{
    """unc-nlp/lxmert-base-uncased""": 5_1_2,
}

snake_case : List[Any]     		=		{
    """unc-nlp/lxmert-base-uncased""": {"""do_lower_case""": True},
}



class        UpperCamelCase__ (				a_):







    """simple docstring"""
    __UpperCAmelCase           = VOCAB_FILES_NAMES
    __UpperCAmelCase           = PRETRAINED_VOCAB_FILES_MAP
    __UpperCAmelCase           = PRETRAINED_INIT_CONFIGURATION
    __UpperCAmelCase           = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    __UpperCAmelCase           = LxmertTokenizer







    def __init__(		self :	Union[str, Any]				,    UpperCamelCase_ :	List[str]=None				,    UpperCamelCase_ :	Dict=None				,    UpperCamelCase_ :	Optional[int]=True				,    UpperCamelCase_ :	Dict="[UNK]"				,    UpperCamelCase_ :	str="[SEP]"				,    UpperCamelCase_ :	Dict="[PAD]"				,    UpperCamelCase_ :	Optional[int]="[CLS]"				,    UpperCamelCase_ :	Any="[MASK]"				,    UpperCamelCase_ :	Any=True				,    UpperCamelCase_ :	List[Any]=None				,    **UpperCamelCase_ :	Dict				,    ):





           '''simple docstring'''

           super().__init__(
               UpperCamelCase_				,    tokenizer_file=UpperCamelCase_				,    do_lower_case=UpperCamelCase_				,    unk_token=UpperCamelCase_				,    sep_token=UpperCamelCase_				,    pad_token=UpperCamelCase_				,    cls_token=UpperCamelCase_				,    mask_token=UpperCamelCase_				,    tokenize_chinese_chars=UpperCamelCase_				,    strip_accents=UpperCamelCase_				,    **UpperCamelCase_				,    )

           __magic_name__      				=    json.loads(self.backend_tokenizer.normalizer.__getstate__() )
           if (
               normalizer_state.get('lowercase'				,    UpperCamelCase_ ) != do_lower_case
               or normalizer_state.get('strip_accents'				,    UpperCamelCase_ ) != strip_accents
               or normalizer_state.get('handle_chinese_chars'				,    UpperCamelCase_ ) != tokenize_chinese_chars
           ):
                  __magic_name__      				=    getattr(UpperCamelCase_				,    normalizer_state.pop('type' ) )
                  __magic_name__      				=    do_lower_case
                  __magic_name__      				=    strip_accents
                  __magic_name__      				=    tokenize_chinese_chars
                  __magic_name__      				=    normalizer_class(**UpperCamelCase_ )

           __magic_name__      				=    do_lower_case







    def 				a__			(		self :	Dict				,    UpperCamelCase_ :	Optional[Any]				,    UpperCamelCase_ :	Optional[int]=None ):





           '''simple docstring'''

           __magic_name__      				=    [self.cls_token_id] + token_ids_a + [self.sep_token_id]

           if token_ids_a:
                  output += token_ids_a + [self.sep_token_id]

           return output







    def 				a__			(		self :	int				,    UpperCamelCase_ :	List[int]				,    UpperCamelCase_ :	Optional[List[int]] = None ):





           '''simple docstring'''

           __magic_name__      				=    [self.sep_token_id]
           __magic_name__      				=    [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 				a__			(		self :	Dict				,    UpperCamelCase_ :	str				,    UpperCamelCase_ :	Optional[str] = None ):





           '''simple docstring'''

           __magic_name__      				=    self._tokenizer.model.save(UpperCamelCase_				,    name=UpperCamelCase_ )
           return tuple(UpperCamelCase_ )