


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


_UpperCAmelCase			:  Tuple     =logging.get_logger(__name__)

_UpperCAmelCase			:  List[Any]     ={
    """facebook/s2t-small-librispeech-asr""": (
        """https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json"""
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  Dict					=							"""speech_to_text"""
						SCREAMING_SNAKE_CASE__      :  Any					=							["""past_key_values"""]
						SCREAMING_SNAKE_CASE__      :  List[str]					=							{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}




						def __init__(				self   ,						__lowercase=1_0_0_0_0   ,						__lowercase=1_2   ,						__lowercase=2_0_4_8   ,						__lowercase=4   ,						__lowercase=6   ,						__lowercase=2_0_4_8   ,						__lowercase=4   ,						__lowercase=0.0   ,						__lowercase=0.0   ,						__lowercase=True   ,						__lowercase=True   ,						__lowercase="relu"   ,						__lowercase=2_5_6   ,						__lowercase=0.1   ,						__lowercase=0.0   ,						__lowercase=0.0   ,						__lowercase=0.02   ,						__lowercase=2   ,						__lowercase=True   ,						__lowercase=1   ,						__lowercase=0   ,						__lowercase=2   ,						__lowercase=6_0_0_0   ,						__lowercase=1_0_2_4   ,						__lowercase=2   ,						__lowercase=(5, 5)   ,						__lowercase=1_0_2_4   ,						__lowercase=8_0   ,						__lowercase=1   ,						**__lowercase   ,						)					->    List[Any]:
										lowerCAmelCase_ :      str    				=				vocab_size
										lowerCAmelCase_ :      Tuple    				=				d_model
										lowerCAmelCase_ :      Union[str, Any]    				=				encoder_ffn_dim
										lowerCAmelCase_ :      Any    				=				encoder_layers
										lowerCAmelCase_ :      Any    				=				encoder_attention_heads
										lowerCAmelCase_ :      List[str]    				=				decoder_ffn_dim
										lowerCAmelCase_ :      str    				=				decoder_layers
										lowerCAmelCase_ :      List[Any]    				=				decoder_attention_heads
										lowerCAmelCase_ :      int    				=				dropout
										lowerCAmelCase_ :      Tuple    				=				attention_dropout
										lowerCAmelCase_ :      int    				=				activation_dropout
										lowerCAmelCase_ :      Dict    				=				activation_function
										lowerCAmelCase_ :      Tuple    				=				init_std
										lowerCAmelCase_ :      List[str]    				=				encoder_layerdrop
										lowerCAmelCase_ :      Optional[int]    				=				decoder_layerdrop
										lowerCAmelCase_ :      Dict    				=				use_cache
										lowerCAmelCase_ :      Union[str, Any]    				=				encoder_layers
										lowerCAmelCase_ :      Any    				=				scale_embedding  # scale factor will be sqrt(d_model) if True
										lowerCAmelCase_ :      Dict    				=				max_source_positions
										lowerCAmelCase_ :      Dict    				=				max_target_positions
										lowerCAmelCase_ :      Tuple    				=				num_conv_layers
										lowerCAmelCase_ :      int    				=				list(__lowercase							)
										lowerCAmelCase_ :      Any    				=				conv_channels
										lowerCAmelCase_ :      Optional[int]    				=				input_feat_per_channel
										lowerCAmelCase_ :      Any    				=				input_channels

										if len(self.conv_kernel_sizes							) != self.num_conv_layers:
														raise ValueError(
														    '''Configuration for convolutional module is incorrect. '''
														    '''It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` '''
														    f"""but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes							)}`, """
														    f"""`config.num_conv_layers = {self.num_conv_layers}`."""							)

										super().__init__(
										    pad_token_id=__lowercase   ,						bos_token_id=__lowercase   ,						eos_token_id=__lowercase   ,						is_encoder_decoder=__lowercase   ,						decoder_start_token_id=__lowercase   ,						**__lowercase   ,						)



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_xlnet import XLNetTokenizer
else:
						_UpperCAmelCase			:  Dict     =None


_UpperCAmelCase			:  Tuple     =logging.get_logger(__name__)

_UpperCAmelCase			:  Any     ={"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

_UpperCAmelCase			:  Any     ={
    """vocab_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/spiece.model""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/spiece.model""",
    },
    """tokenizer_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/tokenizer.json""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/tokenizer.json""",
    },
}

_UpperCAmelCase			:  Dict     ={
    """xlnet-base-cased""": None,
    """xlnet-large-cased""": None,
}

_UpperCAmelCase			:  Tuple     ="""▁"""

# Segments (not really needed)
_UpperCAmelCase			:  str     =0
_UpperCAmelCase			:  List[str]     =1
_UpperCAmelCase			:  int     =2
_UpperCAmelCase			:  Any     =3
_UpperCAmelCase			:  List[Any]     =4







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  int					=							VOCAB_FILES_NAMES
						SCREAMING_SNAKE_CASE__      :  Dict					=							PRETRAINED_VOCAB_FILES_MAP
						SCREAMING_SNAKE_CASE__      :  Optional[Any]					=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						SCREAMING_SNAKE_CASE__      :  Any					=							"""left"""
						SCREAMING_SNAKE_CASE__      :  List[Any]					=							XLNetTokenizer




						def __init__(				self   ,						__lowercase=None   ,						__lowercase=None   ,						__lowercase=False   ,						__lowercase=True   ,						__lowercase=False   ,						__lowercase="<s>"   ,						__lowercase="</s>"   ,						__lowercase="<unk>"   ,						__lowercase="<sep>"   ,						__lowercase="<pad>"   ,						__lowercase="<cls>"   ,						__lowercase="<mask>"   ,						__lowercase=["<eop>", "<eod>"]   ,						**__lowercase   ,						)					->    List[Any]:
										# Mask token behave like a normal word, i.e. include the space before it
										lowerCAmelCase_ :      Any    				=				AddedToken(__lowercase   ,						lstrip=__lowercase   ,						rstrip=__lowercase							) if isinstance(__lowercase   ,						__lowercase							) else mask_token

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

										lowerCAmelCase_ :      List[Any]    				=				3
										lowerCAmelCase_ :      Dict    				=				do_lower_case
										lowerCAmelCase_ :      Dict    				=				remove_space
										lowerCAmelCase_ :      List[str]    				=				keep_accents
										lowerCAmelCase_ :      List[str]    				=				vocab_file
										lowerCAmelCase_ :      str    				=				False if not self.vocab_file else True




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase = None							)					->    List[int]:
										lowerCAmelCase_ :      Tuple    				=				[self.sep_token_id]
										lowerCAmelCase_ :      Any    				=				[self.cls_token_id]
										if token_ids_a is None:
														return token_ids_a + sep + cls
										return token_ids_a + sep + token_ids_a + sep + cls




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase = None							)					->    List[int]:
										lowerCAmelCase_ :      Optional[Any]    				=				[self.sep_token_id]
										lowerCAmelCase_ :      List[Any]    				=				[2]

										if token_ids_a is None:
														return len(token_ids_a + sep							) * [0] + cls_segment_id
										return len(token_ids_a + sep							) * [0] + len(token_ids_a + sep							) * [1] + cls_segment_id




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase = None							)					->    Tuple[str]:
										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(__lowercase							):
														logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""							)
														return
										lowerCAmelCase_ :      str    				=				os.path.join(
										    __lowercase   ,						(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']							)

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

										return (out_vocab_file,)