





'''simple docstring'''




import functools
import operator

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


__SCREAMING_SNAKE_CASE     :int       =				logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE     :List[Any]       =				{
    '''microsoft/unispeech-large-1500h-cv''': (
        '''https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json'''
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Tuple           =							"""unispeech"""




 def __init__(					self       :    Tuple	,			snake_case_       :    Tuple=3_2	,			snake_case_       :    List[str]=7_6_8	,			snake_case_       :    Optional[int]=1_2	,			snake_case_       :    List[str]=1_2	,			snake_case_       :    Tuple=3_0_7_2	,			snake_case_       :    List[str]="gelu"	,			snake_case_       :    List[str]=0.1	,			snake_case_       :    Dict=0.1	,			snake_case_       :    Tuple=0.1	,			snake_case_       :    Any=0.0	,			snake_case_       :    int=0.0	,			snake_case_       :    Tuple=0.1	,			snake_case_       :    Union[str, Any]=0.1	,			snake_case_       :    int=0.0_2	,			snake_case_       :    str=1e-5	,			snake_case_       :    Dict="group"	,			snake_case_       :    Optional[Any]="gelu"	,			snake_case_       :    Optional[Any]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)	,			snake_case_       :    Dict=(5, 2, 2, 2, 2, 2, 2)	,			snake_case_       :    Optional[Any]=(1_0, 3, 3, 3, 3, 2, 2)	,			snake_case_       :    List[Any]=False	,			snake_case_       :    int=1_2_8	,			snake_case_       :    List[Any]=1_6	,			snake_case_       :    Any=False	,			snake_case_       :    Any=True	,			snake_case_       :    int=0.0_5	,			snake_case_       :    Union[str, Any]=1_0	,			snake_case_       :    Union[str, Any]=2	,			snake_case_       :    List[str]=0.0	,			snake_case_       :    Union[str, Any]=1_0	,			snake_case_       :    Dict=0	,			snake_case_       :    Dict=3_2_0	,			snake_case_       :    Tuple=2	,			snake_case_       :    int=0.1	,			snake_case_       :    List[Any]=1_0_0	,			snake_case_       :    Tuple=2_5_6	,			snake_case_       :    Optional[int]=2_5_6	,			snake_case_       :    Dict=0.1	,			snake_case_       :    Dict="mean"	,			snake_case_       :    Union[str, Any]=False	,			snake_case_       :    List[Any]=False	,			snake_case_       :    Dict=2_5_6	,			snake_case_       :    Dict=8_0	,			snake_case_       :    List[Any]=0	,			snake_case_       :    Optional[Any]=1	,			snake_case_       :    Optional[int]=2	,			snake_case_       :    Any=0.5	,			**snake_case_       :    int	,			):
      super().__init__(**snake_case_	,			pad_token_id=snake_case_	,			bos_token_id=snake_case_	,			eos_token_id=snake_case_    )
      _UpperCAmelCase     							=   hidden_size
      _UpperCAmelCase     							=   feat_extract_norm
      _UpperCAmelCase     							=   feat_extract_activation
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   list(snake_case_    )
      _UpperCAmelCase     							=   conv_bias
      _UpperCAmelCase     							=   num_conv_pos_embeddings
      _UpperCAmelCase     							=   num_conv_pos_embedding_groups
      _UpperCAmelCase     							=   len(self.conv_dim    )
      _UpperCAmelCase     							=   num_hidden_layers
      _UpperCAmelCase     							=   intermediate_size
      _UpperCAmelCase     							=   hidden_act
      _UpperCAmelCase     							=   num_attention_heads
      _UpperCAmelCase     							=   hidden_dropout
      _UpperCAmelCase     							=   attention_dropout
      _UpperCAmelCase     							=   activation_dropout
      _UpperCAmelCase     							=   feat_proj_dropout
      _UpperCAmelCase     							=   final_dropout
      _UpperCAmelCase     							=   layerdrop
      _UpperCAmelCase     							=   layer_norm_eps
      _UpperCAmelCase     							=   initializer_range
      _UpperCAmelCase     							=   num_ctc_classes
      _UpperCAmelCase     							=   vocab_size
      _UpperCAmelCase     							=   do_stable_layer_norm
      _UpperCAmelCase     							=   use_weighted_layer_sum
      _UpperCAmelCase     							=   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
      _UpperCAmelCase     							=   apply_spec_augment
      _UpperCAmelCase     							=   mask_time_prob
      _UpperCAmelCase     							=   mask_time_length
      _UpperCAmelCase     							=   mask_time_min_masks
      _UpperCAmelCase     							=   mask_feature_prob
      _UpperCAmelCase     							=   mask_feature_length
      _UpperCAmelCase     							=   mask_feature_min_masks

      # parameters for pretraining with codevector quantized representations
      _UpperCAmelCase     							=   num_codevectors_per_group
      _UpperCAmelCase     							=   num_codevector_groups
      _UpperCAmelCase     							=   contrastive_logits_temperature
      _UpperCAmelCase     							=   feat_quantizer_dropout
      _UpperCAmelCase     							=   num_negatives
      _UpperCAmelCase     							=   codevector_dim
      _UpperCAmelCase     							=   proj_codevector_dim
      _UpperCAmelCase     							=   diversity_loss_weight

      # ctc loss
      _UpperCAmelCase     							=   ctc_loss_reduction
      _UpperCAmelCase     							=   ctc_zero_infinity

      # pretraining loss
      _UpperCAmelCase     							=   replace_prob




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











'''simple docstring'''




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_albert import AlbertTokenizer
else:
  __SCREAMING_SNAKE_CASE     :List[Any]       =				None

__SCREAMING_SNAKE_CASE     :Union[str, Any]       =				logging.get_logger(__name__)
__SCREAMING_SNAKE_CASE     :List[str]       =				{'''vocab_file''': '''spiece.model''', '''tokenizer_file''': '''tokenizer.json'''}

__SCREAMING_SNAKE_CASE     :List[Any]       =				{
    '''vocab_file''': {
        '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/spiece.model''',
        '''albert-large-v1''': '''https://huggingface.co/albert-large-v1/resolve/main/spiece.model''',
        '''albert-xlarge-v1''': '''https://huggingface.co/albert-xlarge-v1/resolve/main/spiece.model''',
        '''albert-xxlarge-v1''': '''https://huggingface.co/albert-xxlarge-v1/resolve/main/spiece.model''',
        '''albert-base-v2''': '''https://huggingface.co/albert-base-v2/resolve/main/spiece.model''',
        '''albert-large-v2''': '''https://huggingface.co/albert-large-v2/resolve/main/spiece.model''',
        '''albert-xlarge-v2''': '''https://huggingface.co/albert-xlarge-v2/resolve/main/spiece.model''',
        '''albert-xxlarge-v2''': '''https://huggingface.co/albert-xxlarge-v2/resolve/main/spiece.model''',
    },
    '''tokenizer_file''': {
        '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/tokenizer.json''',
        '''albert-large-v1''': '''https://huggingface.co/albert-large-v1/resolve/main/tokenizer.json''',
        '''albert-xlarge-v1''': '''https://huggingface.co/albert-xlarge-v1/resolve/main/tokenizer.json''',
        '''albert-xxlarge-v1''': '''https://huggingface.co/albert-xxlarge-v1/resolve/main/tokenizer.json''',
        '''albert-base-v2''': '''https://huggingface.co/albert-base-v2/resolve/main/tokenizer.json''',
        '''albert-large-v2''': '''https://huggingface.co/albert-large-v2/resolve/main/tokenizer.json''',
        '''albert-xlarge-v2''': '''https://huggingface.co/albert-xlarge-v2/resolve/main/tokenizer.json''',
        '''albert-xxlarge-v2''': '''https://huggingface.co/albert-xxlarge-v2/resolve/main/tokenizer.json''',
    },
}

__SCREAMING_SNAKE_CASE     :Optional[Any]       =				{
    '''albert-base-v1''': 512,
    '''albert-large-v1''': 512,
    '''albert-xlarge-v1''': 512,
    '''albert-xxlarge-v1''': 512,
    '''albert-base-v2''': 512,
    '''albert-large-v2''': 512,
    '''albert-xlarge-v2''': 512,
    '''albert-xxlarge-v2''': 512,
}

__SCREAMING_SNAKE_CASE     :Optional[int]       =				'''▁'''







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Optional[int]           =							VOCAB_FILES_NAMES
 _lowerCamelCase  : Any           =							PRETRAINED_VOCAB_FILES_MAP
 _lowerCamelCase  : Tuple           =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 _lowerCamelCase  : int           =							AlbertTokenizer




 def __init__(					self       :    Optional[Any]	,			snake_case_       :    Optional[Any]=None	,			snake_case_       :    Optional[Any]=None	,			snake_case_       :    Optional[Any]=True	,			snake_case_       :    str=True	,			snake_case_       :    Tuple=False	,			snake_case_       :    List[Any]="[CLS]"	,			snake_case_       :    Union[str, Any]="[SEP]"	,			snake_case_       :    str="<unk>"	,			snake_case_       :    Union[str, Any]="[SEP]"	,			snake_case_       :    List[Any]="<pad>"	,			snake_case_       :    List[str]="[CLS]"	,			snake_case_       :    int="[MASK]"	,			**snake_case_       :    Any	,			):
      # 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     							=   (
          AddedToken(snake_case_	,			lstrip=snake_case_	,			rstrip=snake_case_	,			normalized=snake_case_    )
          if isinstance(snake_case_	,			snake_case_    )
          else mask_token
      )

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

      _UpperCAmelCase     							=   do_lower_case
      _UpperCAmelCase     							=   remove_space
      _UpperCAmelCase     							=   keep_accents
      _UpperCAmelCase     							=   vocab_file
      _UpperCAmelCase     							=   False if not self.vocab_file else True




 def      lowercase	(					self       :    Union[str, Any]	,			snake_case_       :    List[int]	,			snake_case_       :    Optional[List[int]] = None    ):
      _UpperCAmelCase     							=   [self.sep_token_id]
      _UpperCAmelCase     							=   [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      lowercase	(					self       :    Dict	,			snake_case_       :    List[int]	,			snake_case_       :    Optional[List[int]] = None    ):
      _UpperCAmelCase     							=   [self.sep_token_id]
      _UpperCAmelCase     							=   [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      lowercase	(					self       :    Optional[Any]	,			snake_case_       :    str	,			snake_case_       :    Optional[str] = None    ):
      if not self.can_save_slow_tokenizer:
           raise ValueError(
               "Your fast tokenizer does not have the necessary information to save the vocabulary for a slow "
               "tokenizer."    )

      if not os.path.isdir(snake_case_    ):
           logger.error(f'Vocabulary path ({save_directory}) should be a directory'    )
           return
      _UpperCAmelCase     							=   os.path.join(
          snake_case_	,			(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]    )

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

      return (out_vocab_file,)




