






"""simple docstring"""



import functools
import operator

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


A__	:    List[Any]			 = logging.get_logger(__name__)

A__	:    Union[str, 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        lowercase__      (							snake_case__       ):
			_UpperCAmelCase		:Any             =			"unispeech"


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

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

										# ctc loss
										lowerCamelCase_	:							Any									=ctc_loss_reduction
										lowerCamelCase_	:							Union[str, Any]									=ctc_zero_infinity

										# pretraining loss
										lowerCamelCase_	:							str									=replace_prob


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











"""simple docstring"""



from typing import List, Optional

from tokenizers import ByteLevelBPETokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_blenderbot_small import BlenderbotSmallTokenizer


A__	:    Dict			 = logging.get_logger(__name__)

A__	:    Dict			 = {
    'vocab_file': 'vocab.json',
    'merges_file': 'merges.txt',
    'tokenizer_config_file': 'tokenizer_config.json',
}

A__	:    List[Any]			 = {
    'vocab_file': {
        'facebook/blenderbot_small-90M': 'https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/vocab.json'
    },
    'merges_file': {
        'facebook/blenderbot_small-90M': 'https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/merges.txt'
    },
    'tokenizer_config_file': {
        'facebook/blenderbot_small-90M': (
            'https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/tokenizer_config.json'
        )
    },
}

A__	:    Optional[int]			 = {
    'facebook/blenderbot_small-90M': 512,
}







class        lowercase__      (							snake_case__       ):
			_UpperCAmelCase		:Optional[int]             =			VOCAB_FILES_NAMES
			_UpperCAmelCase		:Tuple             =			PRETRAINED_VOCAB_FILES_MAP
			_UpperCAmelCase		:Any             =			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_UpperCAmelCase		:Tuple             =			BlenderbotSmallTokenizer


			def __init__(				self					:  Tuple       ,	snake_case__					:  Optional[Any]=None       ,	snake_case__					:  str=None       ,	snake_case__					:  Any="<|endoftext|>"       ,	snake_case__					:  Tuple="<|endoftext|>"       ,	snake_case__					:  Tuple="<|endoftext|>"       ,	snake_case__					:  str=False       ,	snake_case__					:  int=True       ,	**snake_case__					:  Tuple       ,	):
										super().__init__(
										    ByteLevelBPETokenizer(
										        vocab=snake_case__       ,	merges=snake_case__       ,	add_prefix_space=snake_case__       ,	trim_offsets=snake_case__       ,	)       ,	bos_token=snake_case__       ,	eos_token=snake_case__       ,	unk_token=snake_case__       ,	**snake_case__       ,	)
										lowerCamelCase_	:							Optional[int]									=add_prefix_space


			def      UpperCAmelCase__						(				self					:  Tuple       ,	snake_case__					:  Optional[Any]       ,	snake_case__					:  List[str]=None ):
										lowerCamelCase_	:							Optional[Any]									=[self.bos_token_id] + token_ids_a + [self.eos_token_id]
										if token_ids_a is None:
																	return output

										return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]


			def      UpperCAmelCase__						(				self					:  Tuple       ,	snake_case__					:  List[int]       ,	snake_case__					:  Optional[List[int]] = None ):
										lowerCamelCase_	:							int									=[self.sep_token_id]
										lowerCamelCase_	:							List[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 + sep + token_ids_a + sep ) * [0]



