



import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


_lowerCamelCase   :				Union[str, Any]     			=						logging.get_logger(__name__)

_lowerCamelCase   :				Dict     			=						{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_lowerCamelCase   :				List[Any]     			=						[
    '''small''',
    '''small-base''',
    '''medium''',
    '''medium-base''',
    '''intermediate''',
    '''intermediate-base''',
    '''large''',
    '''large-base''',
    '''xlarge''',
    '''xlarge-base''',
]

_lowerCamelCase   :				Optional[Any]     			=						{
    '''vocab_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt''',
        '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt''',
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt''',
        '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json''',
        '''funnel-transformer/small-base''': (
            '''https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json''',
        '''funnel-transformer/large-base''': (
            '''https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'''
        ),
    },
}
_lowerCamelCase   :				Any     			=						{f"""funnel-transformer/{name}""": 5_12 for name in _model_names}
_lowerCamelCase   :				Optional[Any]     			=						{f"""funnel-transformer/{name}""": {'''do_lower_case''': True} for name in _model_names}


class   lowercase      (       a       ):
							lowercase__  :    Optional[int]									=							VOCAB_FILES_NAMES
							lowercase__  :    Optional[Any]									=							PRETRAINED_VOCAB_FILES_MAP
							lowercase__  :    Optional[Any]									=							PRETRAINED_INIT_CONFIGURATION
							lowercase__  :    Union[str, Any]									=							FunnelTokenizer
							lowercase__  :    List[Any]									=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowercase__  :    int									=							2




							def __init__(  self				:   str		,							_UpperCamelCase				:   str=None		,							_UpperCamelCase				:   str=None		,							_UpperCamelCase				:   Union[str, Any]=True		,							_UpperCamelCase				:   str="<unk>"		,							_UpperCamelCase				:   Optional[Any]="<sep>"		,							_UpperCamelCase				:   Optional[int]="<pad>"		,							_UpperCamelCase				:   int="<cls>"		,							_UpperCamelCase				:   Dict="<mask>"		,							_UpperCamelCase				:   Union[str, Any]="<s>"		,							_UpperCamelCase				:   Optional[int]="</s>"		,							_UpperCamelCase				:   Dict=True		,							_UpperCamelCase				:   List[Any]=True		,							_UpperCamelCase				:   Any=None		,							_UpperCamelCase				:   Dict="##"		,							**_UpperCamelCase				:   Dict		,							)   ->			Optional[int]:



												'''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		,							bos_token=_UpperCamelCase		,							eos_token=_UpperCamelCase		,							clean_text=_UpperCamelCase		,							tokenize_chinese_chars=_UpperCamelCase		,							strip_accents=_UpperCamelCase		,							wordpieces_prefix=_UpperCamelCase		,							**_UpperCamelCase		,							)

												SCREAMING_SNAKE_CASE           =    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
												):
																	SCREAMING_SNAKE_CASE           =    getattr(_UpperCamelCase		,							normalizer_state.pop("type" ) )
																	SCREAMING_SNAKE_CASE           =    do_lower_case
																	SCREAMING_SNAKE_CASE           =    strip_accents
																	SCREAMING_SNAKE_CASE           =    tokenize_chinese_chars
																	SCREAMING_SNAKE_CASE           =    normalizer_class(**_UpperCamelCase )

												SCREAMING_SNAKE_CASE           =    do_lower_case




							def 		__snake_case(  self				:   Union[str, Any]		,							_UpperCamelCase				:   Union[str, Any]		,							_UpperCamelCase				:   Dict=None )   ->			List[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE           =    [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				:   int		,							_UpperCamelCase				:   List[int]		,							_UpperCamelCase				:   Optional[List[int]] = None )   ->			List[int]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE           =    [self.sep_token_id]
												SCREAMING_SNAKE_CASE           =    [self.cls_token_id]
												if token_ids_a is None:
																	return len(cls ) * [self.cls_token_type_id] + len(token_ids_a + sep ) * [0]
												return len(cls ) * [self.cls_token_type_id] + len(token_ids_a + sep ) * [0] + len(token_ids_a + sep ) * [1]





							def 		__snake_case(  self				:   Optional[Any]		,							_UpperCamelCase				:   str		,							_UpperCamelCase				:   Optional[str] = None )   ->			Tuple[str]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE           =    self._tokenizer.model.save(_UpperCamelCase		,							name=_UpperCamelCase )
												return tuple(_UpperCamelCase )





import functools
import operator

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


_lowerCamelCase   :				int     			=						logging.get_logger(__name__)

_lowerCamelCase   :				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   lowercase      (       a       ):
							lowercase__  :    Tuple									=							"""unispeech-sat"""




							def __init__(  self				:   str		,							_UpperCamelCase				:   Tuple=32		,							_UpperCamelCase				:   Union[str, Any]=768		,							_UpperCamelCase				:   Tuple=12		,							_UpperCamelCase				:   List[str]=12		,							_UpperCamelCase				:   Tuple=3_072		,							_UpperCamelCase				:   List[str]="gelu"		,							_UpperCamelCase				:   Tuple=0.1		,							_UpperCamelCase				:   Any=0.1		,							_UpperCamelCase				:   Union[str, Any]=0.1		,							_UpperCamelCase				:   Dict=0.0		,							_UpperCamelCase				:   Tuple=0.0		,							_UpperCamelCase				:   Tuple=0.1		,							_UpperCamelCase				:   Optional[Any]=0.1		,							_UpperCamelCase				:   Tuple=0.0_2		,							_UpperCamelCase				:   Optional[int]=1e-5		,							_UpperCamelCase				:   Union[str, Any]="group"		,							_UpperCamelCase				:   Optional[int]="gelu"		,							_UpperCamelCase				:   Tuple=(512, 512, 512, 512, 512, 512, 512)		,							_UpperCamelCase				:   List[str]=(5, 2, 2, 2, 2, 2, 2)		,							_UpperCamelCase				:   Optional[int]=(10, 3, 3, 3, 3, 2, 2)		,							_UpperCamelCase				:   Optional[int]=False		,							_UpperCamelCase				:   Dict=128		,							_UpperCamelCase				:   Optional[int]=16		,							_UpperCamelCase				:   Tuple=False		,							_UpperCamelCase				:   Union[str, Any]=True		,							_UpperCamelCase				:   Optional[Any]=0.0_5		,							_UpperCamelCase				:   Union[str, Any]=10		,							_UpperCamelCase				:   Union[str, Any]=2		,							_UpperCamelCase				:   str=0.0		,							_UpperCamelCase				:   List[Any]=10		,							_UpperCamelCase				:   Optional[int]=0		,							_UpperCamelCase				:   Any=320		,							_UpperCamelCase				:   List[Any]=2		,							_UpperCamelCase				:   str=0.1		,							_UpperCamelCase				:   str=100		,							_UpperCamelCase				:   int=256		,							_UpperCamelCase				:   Optional[Any]=256		,							_UpperCamelCase				:   List[Any]=0.1		,							_UpperCamelCase				:   str="mean"		,							_UpperCamelCase				:   int=False		,							_UpperCamelCase				:   Optional[Any]=False		,							_UpperCamelCase				:   Any=256		,							_UpperCamelCase				:   str=(512, 512, 512, 512, 1_500)		,							_UpperCamelCase				:   List[Any]=(5, 3, 3, 1, 1)		,							_UpperCamelCase				:   Union[str, Any]=(1, 2, 3, 1, 1)		,							_UpperCamelCase				:   Any=512		,							_UpperCamelCase				:   str=0		,							_UpperCamelCase				:   int=1		,							_UpperCamelCase				:   Any=2		,							_UpperCamelCase				:   Optional[Any]=504		,							**_UpperCamelCase				:   str		,							)   ->			int:



												'''simple docstring'''

												super().__init__(**_UpperCamelCase		,							pad_token_id=_UpperCamelCase		,							bos_token_id=_UpperCamelCase		,							eos_token_id=_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    hidden_size
												SCREAMING_SNAKE_CASE           =    feat_extract_norm
												SCREAMING_SNAKE_CASE           =    feat_extract_activation
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    conv_bias
												SCREAMING_SNAKE_CASE           =    num_conv_pos_embeddings
												SCREAMING_SNAKE_CASE           =    num_conv_pos_embedding_groups
												SCREAMING_SNAKE_CASE           =    len(self.conv_dim )
												SCREAMING_SNAKE_CASE           =    num_hidden_layers
												SCREAMING_SNAKE_CASE           =    intermediate_size
												SCREAMING_SNAKE_CASE           =    hidden_act
												SCREAMING_SNAKE_CASE           =    num_attention_heads
												SCREAMING_SNAKE_CASE           =    hidden_dropout
												SCREAMING_SNAKE_CASE           =    attention_dropout
												SCREAMING_SNAKE_CASE           =    activation_dropout
												SCREAMING_SNAKE_CASE           =    feat_proj_dropout
												SCREAMING_SNAKE_CASE           =    final_dropout
												SCREAMING_SNAKE_CASE           =    layerdrop
												SCREAMING_SNAKE_CASE           =    layer_norm_eps
												SCREAMING_SNAKE_CASE           =    initializer_range
												SCREAMING_SNAKE_CASE           =    vocab_size
												SCREAMING_SNAKE_CASE           =    num_clusters
												SCREAMING_SNAKE_CASE           =    do_stable_layer_norm
												SCREAMING_SNAKE_CASE           =    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
												SCREAMING_SNAKE_CASE           =    apply_spec_augment
												SCREAMING_SNAKE_CASE           =    mask_time_prob
												SCREAMING_SNAKE_CASE           =    mask_time_length
												SCREAMING_SNAKE_CASE           =    mask_time_min_masks
												SCREAMING_SNAKE_CASE           =    mask_feature_prob
												SCREAMING_SNAKE_CASE           =    mask_feature_length
												SCREAMING_SNAKE_CASE           =    mask_feature_min_masks

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

												# ctc loss
												SCREAMING_SNAKE_CASE           =    ctc_loss_reduction
												SCREAMING_SNAKE_CASE           =    ctc_zero_infinity

												# SequenceClassification-specific parameter. Feel free to ignore for other classes.
												SCREAMING_SNAKE_CASE           =    classifier_proj_size

												# XVector-specific parameters. Feel free to ignore for other classes.
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    list(_UpperCamelCase )
												SCREAMING_SNAKE_CASE           =    xvector_output_dim





							@property
							def 		__snake_case(  self				:   Tuple )   ->			str:



												'''simple docstring'''

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




