


'''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_fnet import FNetTokenizer
else:
					a_						:       Tuple      			=				None

a_						:       Optional[Any]      			=				logging.get_logger(__name__)
a_						:       Union[str, Any]      			=				{"vocab_file": "spiece.model", "tokenizer_file": "tokenizer.json"}

a_						:       int      			=				{
    "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",
    },
}

a_						:       Optional[int]      			=				{
    "google/fnet-base": 512,
    "google/fnet-large": 512,
}

a_						:       List[Any]      			=				"▁"





class   snake_case					(					lowercase    ):





		"""simple docstring"""




		_lowerCamelCase						=						VOCAB_FILES_NAMES
		_lowerCamelCase						=						PRETRAINED_VOCAB_FILES_MAP
		_lowerCamelCase						=						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		_lowerCamelCase						=						["input_ids", "token_type_ids"]
		_lowerCamelCase						=						FNetTokenizer






		def __init__(					self    ,						UpperCamelCase=None    ,						UpperCamelCase=None    ,						UpperCamelCase=False    ,						UpperCamelCase=True    ,						UpperCamelCase=True    ,						UpperCamelCase="<unk>"    ,						UpperCamelCase="[SEP]"    ,						UpperCamelCase="<pad>"    ,						UpperCamelCase="[CLS]"    ,						UpperCamelCase="[MASK]"    ,						**UpperCamelCase    ,						):







			"""simple docstring"""
			# 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.
			lowerCamelCase_  				=						(
			    AddedToken(__UpperCamelCase    ,						lstrip=__UpperCamelCase    ,						rstrip=__UpperCamelCase    ,						normalized=__UpperCamelCase  )
			    if isinstance(__UpperCamelCase    ,						__UpperCamelCase  )
			    else mask_token
			)

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

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






		def 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = None  ):







			"""simple docstring"""
			lowerCamelCase_  				=						[self.sep_token_id]
			lowerCamelCase_  				=						[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 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = None  ):







			"""simple docstring"""
			lowerCamelCase_  				=						[self.sep_token_id]
			lowerCamelCase_  				=						[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    ,						UpperCamelCase    ,						UpperCamelCase = None  ):







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

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

			return (out_vocab_file,)







'''simple docstring'''

import functools
import operator

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


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

a_						:       Dict      			=				{
    """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   snake_case					(					lowercase    ):





  """simple docstring"""




  _lowerCamelCase						=						"unispeech"






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







   """simple docstring"""
   super().__init__(**UpperCamelCase    ,						pad_token_id=UpperCamelCase    ,						bos_token_id=UpperCamelCase    ,						eos_token_id=UpperCamelCase  )
   lowerCamelCase_  				=						hidden_size
   lowerCamelCase_  				=						feat_extract_norm
   lowerCamelCase_  				=						feat_extract_activation
   lowerCamelCase_  				=						list(UpperCamelCase  )
   lowerCamelCase_  				=						list(UpperCamelCase  )
   lowerCamelCase_  				=						list(UpperCamelCase  )
   lowerCamelCase_  				=						conv_bias
   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
   lowerCamelCase_  				=						mask_feature_min_masks

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

   # ctc loss
   lowerCamelCase_  				=						ctc_loss_reduction
   lowerCamelCase_  				=						ctc_zero_infinity

   # pretraining loss
   lowerCamelCase_  				=						replace_prob







  @property
  def 						snake_case	(					self  ):







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



