



import json
import os
import sys
import tempfile
import unittest
from pathlib import Path
from shutil import copyfile

from huggingface_hub import HfFolder, Repository, create_repo, delete_repo
from requests.exceptions import HTTPError

import transformers
from transformers import (
    CONFIG_MAPPING,
    FEATURE_EXTRACTOR_MAPPING,
    PROCESSOR_MAPPING,
    TOKENIZER_MAPPING,
    AutoConfig,
    AutoFeatureExtractor,
    AutoProcessor,
    AutoTokenizer,
    BertTokenizer,
    ProcessorMixin,
    WavaVecaConfig,
    WavaVecaFeatureExtractor,
    WavaVecaProcessor,
)
from transformers.testing_utils import TOKEN, USER, get_tests_dir, is_staging_test
from transformers.tokenization_utils import TOKENIZER_CONFIG_FILE
from transformers.utils import FEATURE_EXTRACTOR_NAME, is_tokenizers_available


sys.path.append(str(Path(__file__).parent.parent.parent.parent / """utils"""))

from test_module.custom_configuration import CustomConfig  # noqa E402
from test_module.custom_feature_extraction import CustomFeatureExtractor  # noqa E402
from test_module.custom_processing import CustomProcessor  # noqa E402
from test_module.custom_tokenization import CustomTokenizer  # noqa E402


SCREAMING_SNAKE_CASE_				= get_tests_dir("""fixtures/dummy_feature_extractor_config.json""")
SCREAMING_SNAKE_CASE_				= get_tests_dir("""fixtures/vocab.json""")
SCREAMING_SNAKE_CASE_				= get_tests_dir("""fixtures""")




class 			snake_case_						(						unittest.TestCase				):
							__lowerCAmelCase    					=					["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]", "bla", "blou"]






							def snake_case_  (   self      ):
									a_     :      Optional[Any] 						=     0






							def snake_case_  (   self      ):
									a_     :      str 						=     AutoProcessor.from_pretrained("facebook/wav2vec2-base-960h"      )
									self.assertIsInstance(a_			,     a_      )






							def snake_case_  (   self      ):
									with tempfile.TemporaryDirectory() as tmpdirname:
											a_     :      int 						=     WavaVecaConfig()
											a_     :      List[str] 						=     AutoProcessor.from_pretrained("facebook/wav2vec2-base-960h"      )

											# save in new folder
											model_config.save_pretrained(a_      )
											processor.save_pretrained(a_      )

											a_     :      Any 						=     AutoProcessor.from_pretrained(a_      )

									self.assertIsInstance(a_			,     a_      )






							def snake_case_  (   self      ):
									with tempfile.TemporaryDirectory() as tmpdirname:
											# copy relevant files
											copyfile(a_			,     os.path.join(a_			,     a_      )      )
											copyfile(a_			,     os.path.join(a_			,     "vocab.json"      )      )

											a_     :      List[Any] 						=     AutoProcessor.from_pretrained(a_      )

									self.assertIsInstance(a_			,     a_      )






							def snake_case_  (   self      ):
									with tempfile.TemporaryDirectory() as tmpdirname:
											a_     :      str 						=     WavaVecaFeatureExtractor()
											a_     :      List[str] 						=     AutoTokenizer.from_pretrained("facebook/wav2vec2-base-960h"      )

											a_     :      List[str] 						=     WavaVecaProcessor(a_			,     a_      )

											# save in new folder
											processor.save_pretrained(a_      )

											# drop `processor_class` in tokenizer
											with open(os.path.join(a_			,     a_      )			,     "r"      ) as f:
													a_     :      Tuple 						=     json.load(a_      )
													config_dict.pop("processor_class"      )

											with open(os.path.join(a_			,     a_      )			,     "w"      ) as f:
													f.write(json.dumps(a_      )      )

											a_     :      Dict 						=     AutoProcessor.from_pretrained(a_      )

									self.assertIsInstance(a_			,     a_      )






							def snake_case_  (   self      ):
									with tempfile.TemporaryDirectory() as tmpdirname:
											a_     :      Optional[int] 						=     WavaVecaFeatureExtractor()
											a_     :      Optional[Any] 						=     AutoTokenizer.from_pretrained("facebook/wav2vec2-base-960h"      )

											a_     :      List[Any] 						=     WavaVecaProcessor(a_			,     a_      )

											# save in new folder
											processor.save_pretrained(a_      )

											# drop `processor_class` in feature extractor
											with open(os.path.join(a_			,     a_      )			,     "r"      ) as f:
													a_     :      Optional[int] 						=     json.load(a_      )
													config_dict.pop("processor_class"      )

											with open(os.path.join(a_			,     a_      )			,     "w"      ) as f:
													f.write(json.dumps(a_      )      )

											a_     :      Any 						=     AutoProcessor.from_pretrained(a_      )

									self.assertIsInstance(a_			,     a_      )






							def snake_case_  (   self      ):
									with tempfile.TemporaryDirectory() as tmpdirname:
											a_     :      Tuple 						=     WavaVecaConfig(processor_class="Wav2Vec2Processor"      )
											model_config.save_pretrained(a_      )
											# copy relevant files
											copyfile(a_			,     os.path.join(a_			,     "vocab.json"      )      )
											# create emtpy sample processor
											with open(os.path.join(a_			,     a_      )			,     "w"      ) as f:
													f.write("{}"      )

											a_     :      List[str] 						=     AutoProcessor.from_pretrained(a_      )

									self.assertIsInstance(a_			,     a_      )






							def snake_case_  (   self      ):
									# If remote code is not set, we will time out when asking whether to load the model.
									with self.assertRaises(a_      ):
											a_     :      str 						=     AutoProcessor.from_pretrained("hf-internal-testing/test_dynamic_processor"      )
									# If remote code is disabled, we can't load this config.
									with self.assertRaises(a_      ):
											a_     :      Dict 						=     AutoProcessor.from_pretrained(
											    "hf-internal-testing/test_dynamic_processor"			,     trust_remote_code=a_      )

									a_     :      int 						=     AutoProcessor.from_pretrained("hf-internal-testing/test_dynamic_processor"			,     trust_remote_code=a_      )
									self.assertTrue(processor.special_attribute_present      )
									self.assertEqual(processor.__class__.__name__			,     "NewProcessor"      )

									a_     :      str 						=     processor.feature_extractor
									self.assertTrue(feature_extractor.special_attribute_present      )
									self.assertEqual(feature_extractor.__class__.__name__			,     "NewFeatureExtractor"      )

									a_     :      int 						=     processor.tokenizer
									self.assertTrue(tokenizer.special_attribute_present      )
									if is_tokenizers_available():
											self.assertEqual(tokenizer.__class__.__name__			,     "NewTokenizerFast"      )

											# Test we can also load the slow version
											a_     :      Any 						=     AutoProcessor.from_pretrained(
											    "hf-internal-testing/test_dynamic_processor"			,     trust_remote_code=a_			,     use_fast=a_      )
											a_     :      List[Any] 						=     new_processor.tokenizer
											self.assertTrue(new_tokenizer.special_attribute_present      )
											self.assertEqual(new_tokenizer.__class__.__name__			,     "NewTokenizer"      )
									else:
											self.assertEqual(tokenizer.__class__.__name__			,     "NewTokenizer"      )






							def snake_case_  (   self      ):
									try:
											AutoConfig.register("custom"			,     a_      )
											AutoFeatureExtractor.register(a_			,     a_      )
											AutoTokenizer.register(a_			,     slow_tokenizer_class=a_      )
											AutoProcessor.register(a_			,     a_      )
											# Trying to register something existing in the Transformers library will raise an error
											with self.assertRaises(a_      ):
													AutoProcessor.register(a_			,     a_      )

											# Now that the config is registered, it can be used as any other config with the auto-API
											a_     :      Union[str, Any] 						=     CustomFeatureExtractor.from_pretrained(a_      )

											with tempfile.TemporaryDirectory() as tmp_dir:
													a_     :      str 						=     os.path.join(a_			,     "vocab.txt"      )
													with open(a_			,     "w"			,     encoding="utf-8"      ) as vocab_writer:
															vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]      )      )
													a_     :      List[str] 						=     CustomTokenizer(a_      )

											a_     :      Dict 						=     CustomProcessor(a_			,     a_      )

											with tempfile.TemporaryDirectory() as tmp_dir:
													processor.save_pretrained(a_      )
													a_     :      Optional[Any] 						=     AutoProcessor.from_pretrained(a_      )
													self.assertIsInstance(a_			,     a_      )

									finally:
											if "custom" in CONFIG_MAPPING._extra_content:
													del CONFIG_MAPPING._extra_content["custom"]
											if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
													del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]
											if CustomConfig in TOKENIZER_MAPPING._extra_content:
													del TOKENIZER_MAPPING._extra_content[CustomConfig]
											if CustomConfig in PROCESSOR_MAPPING._extra_content:
													del PROCESSOR_MAPPING._extra_content[CustomConfig]






							def snake_case_  (   self      ):




									class 			snake_case_						(						a_				):
																__lowerCAmelCase    					=					False




									class 			snake_case_						(						a_				):
																__lowerCAmelCase    					=					False




									class 			snake_case_						(						a_				):
																__lowerCAmelCase    					=					"AutoFeatureExtractor"
																__lowerCAmelCase    					=					"AutoTokenizer"
																__lowerCAmelCase    					=					False

									try:
											AutoConfig.register("custom"			,     a_      )
											AutoFeatureExtractor.register(a_			,     a_      )
											AutoTokenizer.register(a_			,     slow_tokenizer_class=a_      )
											AutoProcessor.register(a_			,     a_      )
											# If remote code is not set, the default is to use local classes.
											a_     :      List[Any] 						=     AutoProcessor.from_pretrained("hf-internal-testing/test_dynamic_processor"      )
											self.assertEqual(processor.__class__.__name__			,     "NewProcessor"      )
											self.assertFalse(processor.special_attribute_present      )
											self.assertFalse(processor.feature_extractor.special_attribute_present      )
											self.assertFalse(processor.tokenizer.special_attribute_present      )

											# If remote code is disabled, we load the local ones.
											a_     :      Optional[int] 						=     AutoProcessor.from_pretrained(
											    "hf-internal-testing/test_dynamic_processor"			,     trust_remote_code=a_      )
											self.assertEqual(processor.__class__.__name__			,     "NewProcessor"      )
											self.assertFalse(processor.special_attribute_present      )
											self.assertFalse(processor.feature_extractor.special_attribute_present      )
											self.assertFalse(processor.tokenizer.special_attribute_present      )

											# If remote is enabled, we load from the Hub.
											a_     :      Union[str, Any] 						=     AutoProcessor.from_pretrained(
											    "hf-internal-testing/test_dynamic_processor"			,     trust_remote_code=a_      )
											self.assertEqual(processor.__class__.__name__			,     "NewProcessor"      )
											self.assertTrue(processor.special_attribute_present      )
											self.assertTrue(processor.feature_extractor.special_attribute_present      )
											self.assertTrue(processor.tokenizer.special_attribute_present      )

									finally:
											if "custom" in CONFIG_MAPPING._extra_content:
													del CONFIG_MAPPING._extra_content["custom"]
											if CustomConfig in FEATURE_EXTRACTOR_MAPPING._extra_content:
													del FEATURE_EXTRACTOR_MAPPING._extra_content[CustomConfig]
											if CustomConfig in TOKENIZER_MAPPING._extra_content:
													del TOKENIZER_MAPPING._extra_content[CustomConfig]
											if CustomConfig in PROCESSOR_MAPPING._extra_content:
													del PROCESSOR_MAPPING._extra_content[CustomConfig]






							def snake_case_  (   self      ):
									a_     :      Optional[int] 						=     AutoProcessor.from_pretrained("hf-internal-testing/tiny-random-bert"      )
									self.assertEqual(processor.__class__.__name__			,     "BertTokenizerFast"      )






							def snake_case_  (   self      ):
									a_     :      Optional[int] 						=     AutoProcessor.from_pretrained("hf-internal-testing/tiny-random-convnext"      )
									self.assertEqual(processor.__class__.__name__			,     "ConvNextImageProcessor"      )




@is_staging_test
class 			snake_case_						(						unittest.TestCase				):
							__lowerCAmelCase    					=					["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]", "bla", "blou"]






							@classmethod
							def snake_case_  (   cls      ):
									a_     :      Optional[int] 						=     TOKEN
									HfFolder.save_token(a_      )






							@classmethod
							def snake_case_  (   cls      ):
									try:
											delete_repo(token=cls._token			,     repo_id="test-processor"      )
									except HTTPError:
											pass

									try:
											delete_repo(token=cls._token			,     repo_id="valid_org/test-processor-org"      )
									except HTTPError:
											pass

									try:
											delete_repo(token=cls._token			,     repo_id="test-dynamic-processor"      )
									except HTTPError:
											pass






							def snake_case_  (   self      ):
									a_     :      str 						=     WavaVecaProcessor.from_pretrained(a_      )
									with tempfile.TemporaryDirectory() as tmp_dir:
											processor.save_pretrained(
											    os.path.join(a_			,     "test-processor"      )			,     push_to_hub=a_			,     use_auth_token=self._token      )

											a_     :      Dict 						=     WavaVecaProcessor.from_pretrained(F"""{USER}/test-processor"""      )
											for k, v in processor.feature_extractor.__dict__.items():
													self.assertEqual(a_			,     getattr(new_processor.feature_extractor			,     a_      )      )
											self.assertDictEqual(new_processor.tokenizer.get_vocab()			,     processor.tokenizer.get_vocab()      )






							def snake_case_  (   self      ):
									a_     :      List[str] 						=     WavaVecaProcessor.from_pretrained(a_      )

									with tempfile.TemporaryDirectory() as tmp_dir:
											processor.save_pretrained(
											    os.path.join(a_			,     "test-processor-org"      )			,     push_to_hub=a_			,     use_auth_token=self._token			,     organization="valid_org"			,     )

											a_     :      Optional[Any] 						=     WavaVecaProcessor.from_pretrained("valid_org/test-processor-org"      )
											for k, v in processor.feature_extractor.__dict__.items():
													self.assertEqual(a_			,     getattr(new_processor.feature_extractor			,     a_      )      )
											self.assertDictEqual(new_processor.tokenizer.get_vocab()			,     processor.tokenizer.get_vocab()      )






							def snake_case_  (   self      ):
									CustomFeatureExtractor.register_for_auto_class()
									CustomTokenizer.register_for_auto_class()
									CustomProcessor.register_for_auto_class()

									a_     :      List[Any] 						=     CustomFeatureExtractor.from_pretrained(a_      )

									with tempfile.TemporaryDirectory() as tmp_dir:
											a_     :      str 						=     os.path.join(a_			,     "vocab.txt"      )
											with open(a_			,     "w"			,     encoding="utf-8"      ) as vocab_writer:
													vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]      )      )
											a_     :      Union[str, Any] 						=     CustomTokenizer(a_      )

									a_     :      int 						=     CustomProcessor(a_			,     a_      )

									with tempfile.TemporaryDirectory() as tmp_dir:
											create_repo(F"""{USER}/test-dynamic-processor"""			,     token=self._token      )
											a_     :      Any 						=     Repository(a_			,     clone_from=F"""{USER}/test-dynamic-processor"""			,     token=self._token      )
											processor.save_pretrained(a_      )

											# This has added the proper auto_map field to the feature extractor config
											self.assertDictEqual(
											    processor.feature_extractor.auto_map			,     {
											        "AutoFeatureExtractor": "custom_feature_extraction.CustomFeatureExtractor",
											        "AutoProcessor": "custom_processing.CustomProcessor",
											    }			,     )

											# This has added the proper auto_map field to the tokenizer config
											with open(os.path.join(a_			,     "tokenizer_config.json"      )      ) as f:
													a_     :      List[Any] 						=     json.load(a_      )
											self.assertDictEqual(
											    tokenizer_config["auto_map"]			,     {
											        "AutoTokenizer": ["custom_tokenization.CustomTokenizer", None],
											        "AutoProcessor": "custom_processing.CustomProcessor",
											    }			,     )

											# The code has been copied from fixtures
											self.assertTrue(os.path.isfile(os.path.join(a_			,     "custom_feature_extraction.py"      )      )      )
											self.assertTrue(os.path.isfile(os.path.join(a_			,     "custom_tokenization.py"      )      )      )
											self.assertTrue(os.path.isfile(os.path.join(a_			,     "custom_processing.py"      )      )      )

											repo.push_to_hub()

									a_     :      List[str] 						=     AutoProcessor.from_pretrained(F"""{USER}/test-dynamic-processor"""			,     trust_remote_code=a_      )
									# Can't make an isinstance check because the new_processor is from the CustomProcessor class of a dynamic module
									self.assertEqual(new_processor.__class__.__name__			,     "CustomProcessor"      )




"""simple docstring"""
import unittest

from transformers import SPIECE_UNDERLINE
from transformers.models.speechta import SpeechTaTokenizer
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow
from transformers.tokenization_utils import AddedToken

from ...test_tokenization_common import TokenizerTesterMixin


SCREAMING_SNAKE_CASE_				= get_tests_dir("""fixtures/test_sentencepiece_bpe_char.model""")




@require_sentencepiece
@require_tokenizers
class 			snake_case_						(						a_     ,unittest.TestCase				):
							__lowerCAmelCase    					=					SpeechTaTokenizer
							__lowerCAmelCase    					=					False
							__lowerCAmelCase    					=					True






							def snake_case_  (   self      ):
									super().setUp()

									# We have a SentencePiece fixture for testing
									a_     :      Any 						=     SpeechTaTokenizer(a_      )

									a_     :      Optional[int] 						=     AddedToken("<mask>"			,     lstrip=a_			,     rstrip=a_      )
									a_     :      Any 						=     mask_token
									tokenizer.add_special_tokens({"mask_token": mask_token}      )
									tokenizer.add_tokens(["<ctc_blank>"]      )

									tokenizer.save_pretrained(self.tmpdirname      )






							def snake_case_  (   self			,     a_      ):
									a_     :      Tuple 						=     "this is a test"
									a_     :      Any 						=     "this is a test"
									return input_text, output_text






							def snake_case_  (   self			,     a_			,     a_=False			,     a_=2_0			,     a_=5      ):
									a_						,				a_     :      Optional[Any] 						=     self.get_input_output_texts(a_      )
									a_     :      Optional[Any] 						=     tokenizer.encode(a_			,     add_special_tokens=a_      )
									a_     :      Dict 						=     tokenizer.decode(a_			,     clean_up_tokenization_spaces=a_      )
									return text, ids






							def snake_case_  (   self      ):
									a_     :      List[Any] 						=     "<pad>"
									a_     :      Optional[int] 						=     1

									self.assertEqual(self.get_tokenizer()._convert_token_to_id(a_      )			,     a_      )
									self.assertEqual(self.get_tokenizer()._convert_id_to_token(a_      )			,     a_      )






							def snake_case_  (   self      ):
									a_     :      List[Any] 						=     list(self.get_tokenizer().get_vocab().keys()      )

									self.assertEqual(vocab_keys[0]			,     "<s>"      )
									self.assertEqual(vocab_keys[1]			,     "<pad>"      )
									self.assertEqual(vocab_keys[-4]			,     "œ"      )
									self.assertEqual(vocab_keys[-2]			,     "<mask>"      )
									self.assertEqual(vocab_keys[-1]			,     "<ctc_blank>"      )
									self.assertEqual(len(a_      )			,     8_1      )






							def snake_case_  (   self      ):
									self.assertEqual(self.get_tokenizer().vocab_size			,     7_9      )






							def snake_case_  (   self      ):
									a_     :      Any 						=     self.get_tokenizers(do_lower_case=a_      )
									for tokenizer in tokenizers:
											with self.subTest(F"""{tokenizer.__class__.__name__}"""      ):
													a_     :      Dict 						=     tokenizer.vocab_size
													a_     :      List[str] 						=     len(a_      )

													self.assertNotEqual(a_			,     0      )

													# We usually have added tokens from the start in tests because our vocab fixtures are
													# smaller than the original vocabs - let's not assert this
													# self.assertEqual(vocab_size, all_size)

													a_     :      Optional[int] 						=     ["aaaaa bbbbbb", "cccccccccdddddddd"]
													a_     :      int 						=     tokenizer.add_tokens(a_      )
													a_     :      List[Any] 						=     tokenizer.vocab_size
													a_     :      Tuple 						=     len(a_      )

													self.assertNotEqual(a_			,     0      )
													self.assertEqual(a_			,     a_      )
													self.assertEqual(a_			,     len(a_      )      )
													self.assertEqual(a_			,     all_size + len(a_      )      )

													a_     :      str 						=     tokenizer.encode("aaaaa bbbbbb low cccccccccdddddddd l"			,     add_special_tokens=a_      )

													self.assertGreaterEqual(len(a_      )			,     4      )
													self.assertGreater(tokens[0]			,     tokenizer.vocab_size - 1      )
													self.assertGreater(tokens[-3]			,     tokenizer.vocab_size - 1      )

													a_     :      Tuple 						=     {"eos_token": ">>>>|||<||<<|<<", "pad_token": "<<<<<|||>|>>>>|>"}
													a_     :      Dict 						=     tokenizer.add_special_tokens(a_      )
													a_     :      Optional[Any] 						=     tokenizer.vocab_size
													a_     :      Any 						=     len(a_      )

													self.assertNotEqual(a_			,     0      )
													self.assertEqual(a_			,     a_      )
													self.assertEqual(a_			,     len(a_      )      )
													self.assertEqual(a_			,     all_size_a + len(a_      )      )

													a_     :      Any 						=     tokenizer.encode(
													    ">>>>|||<||<<|<< aaaaabbbbbb low cccccccccdddddddd <<<<<|||>|>>>>|> l"			,     add_special_tokens=a_      )

													self.assertGreaterEqual(len(a_      )			,     6      )
													self.assertGreater(tokens[0]			,     tokenizer.vocab_size - 1      )
													self.assertGreater(tokens[0]			,     tokens[1]      )
													self.assertGreater(tokens[-3]			,     tokenizer.vocab_size - 1      )
													self.assertGreater(tokens[-3]			,     tokens[-4]      )
													self.assertEqual(tokens[0]			,     tokenizer.eos_token_id      )
													self.assertEqual(tokens[-3]			,     tokenizer.pad_token_id      )






							def snake_case_  (   self      ):
									pass






							def snake_case_  (   self      ):
									pass






							def snake_case_  (   self      ):
									a_     :      Union[str, Any] 						=     self.get_tokenizer()

									a_     :      Any 						=     tokenizer.tokenize("This is a test"      )
									# fmt: off
									self.assertListEqual(a_			,     [SPIECE_UNDERLINE, "T", "h", "i", "s", SPIECE_UNDERLINE, "i", "s", SPIECE_UNDERLINE, "a", SPIECE_UNDERLINE, "t", "e", "s", "t"]      )
									# fmt: on

									self.assertListEqual(
									    tokenizer.convert_tokens_to_ids(a_      )			,     [4, 3_2, 1_1, 1_0, 1_2, 4, 1_0, 1_2, 4, 7, 4, 6, 5, 1_2, 6]			,     )

									a_     :      Optional[int] 						=     tokenizer.tokenize("I was born in 92000, and this is falsé."      )
									self.assertListEqual(
									    a_			,     [SPIECE_UNDERLINE, "I", SPIECE_UNDERLINE, "w", "a", "s", SPIECE_UNDERLINE, "b", "o", "r", "n", SPIECE_UNDERLINE, "i", "n", SPIECE_UNDERLINE, "92000", ",", SPIECE_UNDERLINE, "a", "n", "d", SPIECE_UNDERLINE, "t", "h", "i", "s", SPIECE_UNDERLINE, "i", "s", SPIECE_UNDERLINE, "f", "a", "l", "s", "é", "."]      )

									a_     :      Tuple 						=     tokenizer.convert_tokens_to_ids(a_      )
									# fmt: off
									self.assertListEqual(a_			,     [4, 3_0, 4, 2_0, 7, 1_2, 4, 2_5, 8, 1_3, 9, 4, 1_0, 9, 4, 3, 2_3, 4, 7, 9, 1_4, 4, 6, 1_1, 1_0, 1_2, 4, 1_0, 1_2, 4, 1_9, 7, 1_5, 1_2, 7_3, 2_6]      )
									# fmt: on

									a_     :      Tuple 						=     tokenizer.convert_ids_to_tokens(a_      )
									self.assertListEqual(
									    a_			,     [SPIECE_UNDERLINE, "I", SPIECE_UNDERLINE, "w", "a", "s", SPIECE_UNDERLINE, "b", "o", "r", "n", SPIECE_UNDERLINE, "i", "n", SPIECE_UNDERLINE, "<unk>", ",", SPIECE_UNDERLINE, "a", "n", "d", SPIECE_UNDERLINE, "t", "h", "i", "s", SPIECE_UNDERLINE, "i", "s", SPIECE_UNDERLINE, "f", "a", "l", "s", "é", "."]      )






							@slow
							def snake_case_  (   self      ):
									# Use custom sequence because this tokenizer does not handle numbers.
									a_     :      List[Any] 						=     [
									    "Transformers (formerly known as pytorch-transformers and pytorch-pretrained-bert) provides "
									    "general-purpose architectures (BERT, GPT, RoBERTa, XLM, DistilBert, XLNet...) for Natural "
									    "Language Understanding (NLU) and Natural Language Generation (NLG) with over thirty-two pretrained "
									    "models in one hundred plus languages and deep interoperability between Jax, PyTorch and TensorFlow.",
									    "BERT is designed to pre-train deep bidirectional representations from unlabeled text by jointly "
									    "conditioning on both left and right context in all layers.",
									    "The quick brown fox jumps over the lazy dog.",
									]

									# fmt: off
									a_     :      Tuple 						=     {
									    "input_ids": [
									        [4, 3_2, 1_3, 7, 9, 1_2, 1_9, 8, 1_3, 1_8, 5, 1_3, 1_2, 4, 6_4, 1_9, 8, 1_3, 1_8, 5, 1_3, 1_5, 2_2, 4, 2_8, 9, 8, 2_0, 9, 4, 7, 1_2, 4, 2_4, 2_2, 6, 8, 1_3, 1_7, 1_1, 3_9, 6, 1_3, 7, 9, 1_2, 1_9, 8, 1_3, 1_8, 5, 1_3, 1_2, 4, 7, 9, 1_4, 4, 2_4, 2_2, 6, 8, 1_3, 1_7, 1_1, 3_9, 2_4, 1_3, 5, 6, 1_3, 7, 1_0, 9, 5, 1_4, 3_9, 2_5, 5, 1_3, 6, 6_3, 4, 2_4, 1_3, 8, 2_7, 1_0, 1_4, 5, 1_2, 4, 2_1, 5, 9, 5, 1_3, 7, 1_5, 3_9, 2_4, 1_6, 1_3, 2_4, 8, 1_2, 5, 4, 7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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
									    ]
									}
									# fmt: on

									self.tokenizer_integration_test_util(
									    expected_encoding=a_			,     model_name="microsoft/speecht5_asr"			,     revision="c5ef64c71905caeccde0e4462ef3f9077224c524"			,     sequences=a_			,     )