




'''simple docstring'''







import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_distilbert import DistilBertTokenizer


lowercase      :   List[str]      =       logging.get_logger(__name__)

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

lowercase      :   str      =       {
    """vocab_file""": {
        """distilbert-base-uncased""": """https://huggingface.co/distilbert-base-uncased/resolve/main/vocab.txt""",
        """distilbert-base-uncased-distilled-squad""": (
            """https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/vocab.txt"""
        ),
        """distilbert-base-cased""": """https://huggingface.co/distilbert-base-cased/resolve/main/vocab.txt""",
        """distilbert-base-cased-distilled-squad""": (
            """https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/vocab.txt"""
        ),
        """distilbert-base-german-cased""": """https://huggingface.co/distilbert-base-german-cased/resolve/main/vocab.txt""",
        """distilbert-base-multilingual-cased""": (
            """https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/vocab.txt"""
        ),
    },
    """tokenizer_file""": {
        """distilbert-base-uncased""": """https://huggingface.co/distilbert-base-uncased/resolve/main/tokenizer.json""",
        """distilbert-base-uncased-distilled-squad""": (
            """https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/tokenizer.json"""
        ),
        """distilbert-base-cased""": """https://huggingface.co/distilbert-base-cased/resolve/main/tokenizer.json""",
        """distilbert-base-cased-distilled-squad""": (
            """https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/tokenizer.json"""
        ),
        """distilbert-base-german-cased""": (
            """https://huggingface.co/distilbert-base-german-cased/resolve/main/tokenizer.json"""
        ),
        """distilbert-base-multilingual-cased""": (
            """https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/tokenizer.json"""
        ),
    },
}

lowercase      :   Any      =       {
    """distilbert-base-uncased""": 512,
    """distilbert-base-uncased-distilled-squad""": 512,
    """distilbert-base-cased""": 512,
    """distilbert-base-cased-distilled-squad""": 512,
    """distilbert-base-german-cased""": 512,
    """distilbert-base-multilingual-cased""": 512,
}


lowercase      :   Union[str, Any]      =       {
    """distilbert-base-uncased""": {"""do_lower_case""": True},
    """distilbert-base-uncased-distilled-squad""": {"""do_lower_case""": True},
    """distilbert-base-cased""": {"""do_lower_case""": False},
    """distilbert-base-cased-distilled-squad""": {"""do_lower_case""": False},
    """distilbert-base-german-cased""": {"""do_lower_case""": False},
    """distilbert-base-multilingual-cased""": {"""do_lower_case""": False},
}







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Tuple          =					VOCAB_FILES_NAMES
     lowerCAmelCase_  :     Union[str, Any]          =					PRETRAINED_VOCAB_FILES_MAP
     lowerCAmelCase_  :     Optional[Any]          =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     lowerCAmelCase_  :     Tuple          =					PRETRAINED_INIT_CONFIGURATION
     lowerCAmelCase_  :     List[str]          =					["""input_ids""", """attention_mask"""]
     lowerCAmelCase_  :     Union[str, Any]          =					DistilBertTokenizer







     def __init__(				self							,__a=None							,__a=None							,__a=True							,__a="[UNK]"							,__a="[SEP]"							,__a="[PAD]"							,__a="[CLS]"							,__a="[MASK]"							,__a=True							,__a=None							,**__a							,)      ->				List[Any]:
          super().__init__(
              __a							,tokenizer_file=__a							,do_lower_case=__a							,unk_token=__a							,sep_token=__a							,pad_token=__a							,cls_token=__a							,mask_token=__a							,tokenize_chinese_chars=__a							,strip_accents=__a							,**__a							,)

          snake_case			:      Union[str, Any]        =			json.loads(self.backend_tokenizer.normalizer.__getstate__()							)
          if (
              normalizer_state.get("""lowercase"""							,__a							) != do_lower_case
              or normalizer_state.get("""strip_accents"""							,__a							) != strip_accents
              or normalizer_state.get("""handle_chinese_chars"""							,__a							) != tokenize_chinese_chars
          ):
               snake_case			:      List[Any]        =			getattr(__a							,normalizer_state.pop("""type"""							)							)
               snake_case			:      List[Any]        =			do_lower_case
               snake_case			:      Dict        =			strip_accents
               snake_case			:      str        =			tokenize_chinese_chars
               snake_case			:      Union[str, Any]        =			normalizer_class(**__a							)

          snake_case			:      Dict        =			do_lower_case







     def 			snake_case_      (				self							,__a							,__a=None							)      ->				str:
          snake_case			:      List[Any]        =			[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 			snake_case_      (				self							,__a							,__a = None							)      ->				List[int]:
          snake_case			:      Optional[Any]        =			[self.sep_token_id]
          snake_case			:      Union[str, 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 			snake_case_      (				self							,__a							,__a = None							)      ->				Tuple[str]:
          snake_case			:      int        =			self._tokenizer.model.save(__a							,name=__a							)
          return tuple(__a							)









'''simple docstring'''







import functools
import operator

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


lowercase      :   Optional[int]      =       logging.get_logger(__name__)

lowercase      :   Union[str, Any]      =       {
    """microsoft/unispeech-sat-base-100h-libri-ft""": (
        """https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json"""
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     List[Any]          =					"""unispeech-sat"""







     def __init__(				self							,__a=32							,__a=768							,__a=12							,__a=12							,__a=3_072							,__a="gelu"							,__a=0.1							,__a=0.1							,__a=0.1							,__a=0.0							,__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=False							,__a=True							,__a=0.05							,__a=10							,__a=2							,__a=0.0							,__a=10							,__a=0							,__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, 1_500)							,__a=(5, 3, 3, 1, 1)							,__a=(1, 2, 3, 1, 1)							,__a=512							,__a=0							,__a=1							,__a=2							,__a=504							,**__a							,)      ->				str:
          super().__init__(**__a							,pad_token_id=__a							,bos_token_id=__a							,eos_token_id=__a							)
          snake_case			:      List[Any]        =			hidden_size
          snake_case			:      Any        =			feat_extract_norm
          snake_case			:      Dict        =			feat_extract_activation
          snake_case			:      List[Any]        =			list(__a							)
          snake_case			:      int        =			list(__a							)
          snake_case			:      Dict        =			list(__a							)
          snake_case			:      int        =			conv_bias
          snake_case			:      Optional[Any]        =			num_conv_pos_embeddings
          snake_case			:      Any        =			num_conv_pos_embedding_groups
          snake_case			:      Dict        =			len(self.conv_dim							)
          snake_case			:      str        =			num_hidden_layers
          snake_case			:      Optional[Any]        =			intermediate_size
          snake_case			:      Optional[Any]        =			hidden_act
          snake_case			:      Union[str, Any]        =			num_attention_heads
          snake_case			:      str        =			hidden_dropout
          snake_case			:      Tuple        =			attention_dropout
          snake_case			:      Tuple        =			activation_dropout
          snake_case			:      List[Any]        =			feat_proj_dropout
          snake_case			:      List[str]        =			final_dropout
          snake_case			:      Union[str, Any]        =			layerdrop
          snake_case			:      Optional[int]        =			layer_norm_eps
          snake_case			:      int        =			initializer_range
          snake_case			:      List[Any]        =			vocab_size
          snake_case			:      Any        =			num_clusters
          snake_case			:      Dict        =			do_stable_layer_norm
          snake_case			:      int        =			use_weighted_layer_sum

          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
          snake_case			:      Dict        =			apply_spec_augment
          snake_case			:      Optional[int]        =			mask_time_prob
          snake_case			:      int        =			mask_time_length
          snake_case			:      int        =			mask_time_min_masks
          snake_case			:      int        =			mask_feature_prob
          snake_case			:      Optional[Any]        =			mask_feature_length
          snake_case			:      List[Any]        =			mask_feature_min_masks

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

          # ctc loss
          snake_case			:      Union[str, Any]        =			ctc_loss_reduction
          snake_case			:      Optional[int]        =			ctc_zero_infinity

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

          # XVector-specific parameters. Feel free to ignore for other classes.
          snake_case			:      int        =			list(__a							)
          snake_case			:      Tuple        =			list(__a							)
          snake_case			:      List[Any]        =			list(__a							)
          snake_case			:      Dict        =			xvector_output_dim







     @property
     def 			snake_case_      (				self							)      ->				List[str]:
          return functools.reduce(operator.mul							,self.conv_stride							,1							)



