


"""simple docstring"""



import inspect
import unittest
from math import floor

from transformers import CvtConfig
from transformers.file_utils import cached_property, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import CvtForImageClassification, CvtModel
  from transformers.models.cvt.modeling_cvt import CVT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
  from PIL import Image

  from transformers import AutoImageProcessor







class _lowerCAmelCase							( snake_case_      ):







   def 					lowerCamelCase						(      self		)      ->						Dict:

       '''simple docstring'''




       snake_case       : Optional[Any]    =       self.config_class(**self.inputs_dict		)
       self.parent.assertTrue(hasattr(UpperCamelCase__		,      "embed_dim"		)		)
       self.parent.assertTrue(hasattr(UpperCamelCase__		,      "num_heads"		)		)







class _lowerCAmelCase							:







   def __init__(      self		,      UpperCamelCase__		,      UpperCamelCase__=13		,      UpperCamelCase__=64		,      UpperCamelCase__=3		,      UpperCamelCase__=[16, 48, 96]		,      UpperCamelCase__=[1, 3, 6]		,      UpperCamelCase__=[1, 2, 10]		,      UpperCamelCase__=[7, 3, 3]		,      UpperCamelCase__=[4, 2, 2]		,      UpperCamelCase__=[2, 1, 1]		,      UpperCamelCase__=[2, 2, 2]		,      UpperCamelCase__=[False, False, True]		,      UpperCamelCase__=[0.0, 0.0, 0.0]		,      UpperCamelCase__=0.02		,      UpperCamelCase__=1e-12		,      UpperCamelCase__=True		,      UpperCamelCase__=True		,      UpperCamelCase__=2		,      )      ->						Optional[Any]:

       '''simple docstring'''




       snake_case       : List[str]    =       parent
       snake_case       : Dict    =       batch_size
       snake_case       : Dict    =       image_size
       snake_case       : Dict    =       patch_sizes
       snake_case       : List[str]    =       patch_stride
       snake_case       : List[Any]    =       patch_padding
       snake_case       : Optional[Any]    =       is_training
       snake_case       : Optional[int]    =       use_labels
       snake_case       : Optional[Any]    =       num_labels
       snake_case       : Union[str, Any]    =       num_channels
       snake_case       : Tuple    =       embed_dim
       snake_case       : Tuple    =       num_heads
       snake_case       : int    =       stride_kv
       snake_case       : Union[str, Any]    =       depth
       snake_case       : str    =       cls_token
       snake_case       : List[Any]    =       attention_drop_rate
       snake_case       : Union[str, Any]    =       initializer_range
       snake_case       : Any    =       layer_norm_eps







   def 					lowerCamelCase						(      self		)      ->						Union[str, Any]:

       '''simple docstring'''




       snake_case       : int    =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]		)

       snake_case       : List[str]    =       None
       if self.use_labels:
           snake_case       : int    =       ids_tensor([self.batch_size]		,      self.num_labels		)

       snake_case       : Optional[Any]    =       self.get_config()
       return config, pixel_values, labels







   def 					lowerCamelCase						(      self		)      ->						List[str]:

       '''simple docstring'''




       return CvtConfig(
           image_size=self.image_size		,      num_labels=self.num_labels		,      num_channels=self.num_channels		,      embed_dim=self.embed_dim		,      num_heads=self.num_heads		,      patch_sizes=self.patch_sizes		,      patch_padding=self.patch_padding		,      patch_stride=self.patch_stride		,      stride_kv=self.stride_kv		,      depth=self.depth		,      cls_token=self.cls_token		,      attention_drop_rate=self.attention_drop_rate		,      initializer_range=self.initializer_range		,      )







   def 					lowerCamelCase						(      self		,      UpperCamelCase__		,      UpperCamelCase__		,      UpperCamelCase__		)      ->						int:

       '''simple docstring'''




       snake_case       : Optional[Any]    =       CvtModel(config=UpperCamelCase__		)
       model.to(UpperCamelCase__		)
       model.eval()
       snake_case       : Union[str, Any]    =       model(UpperCamelCase__		)
       snake_case       : Tuple    =       (self.image_size, self.image_size)
       snake_case   ,snake_case       : List[Any]    =       image_size[0], image_size[1]
       for i in range(len(self.depth		)		):
           snake_case       : str    =       floor(((height + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1		)
           snake_case       : List[str]    =       floor(((width + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1		)
       self.parent.assertEqual(result.last_hidden_state.shape		,      (self.batch_size, self.embed_dim[-1], height, width)		)







   def 					lowerCamelCase						(      self		,      UpperCamelCase__		,      UpperCamelCase__		,      UpperCamelCase__		)      ->						Optional[int]:

       '''simple docstring'''




       snake_case       : str    =       self.num_labels
       snake_case       : List[Any]    =       CvtForImageClassification(UpperCamelCase__		)
       model.to(UpperCamelCase__		)
       model.eval()
       snake_case       : Tuple    =       model(UpperCamelCase__		,      labels=UpperCamelCase__		)
       self.parent.assertEqual(result.logits.shape		,      (self.batch_size, self.num_labels)		)







   def 					lowerCamelCase						(      self		)      ->						Tuple:

       '''simple docstring'''




       snake_case       : str    =       self.prepare_config_and_inputs()
       snake_case   ,snake_case   ,snake_case       : List[Any]    =       config_and_inputs
       snake_case       : Dict    =       {"pixel_values": pixel_values}
       return config, inputs_dict







@require_torch
class _lowerCAmelCase							( snake_case_       ,				snake_case_       ,				unittest.TestCase      ):
   __UpperCAmelCase					:			int				    =    (CvtModel, CvtForImageClassification) if is_torch_available() else ()
   __UpperCAmelCase					:			Any				    =    (
       {'''feature-extraction''': CvtModel, '''image-classification''': CvtForImageClassification}
       if is_torch_available()
       else {}
   )

   __UpperCAmelCase					:			Optional[int]				    =    False
   __UpperCAmelCase					:			Optional[int]				    =    False
   __UpperCAmelCase					:			Optional[Any]				    =    False
   __UpperCAmelCase					:			List[Any]				    =    False
   __UpperCAmelCase					:			Optional[int]				    =    False







   def 					lowerCamelCase						(      self		)      ->						List[str]:

       '''simple docstring'''




       snake_case       : Any    =       CvtModelTester(self		)
       snake_case       : int    =       ConfigTester(self		,      config_class=UpperCamelCase__		,      has_text_modality=UpperCamelCase__		,      hidden_size=37		)







   def 					lowerCamelCase						(      self		)      ->						Any:

       '''simple docstring'''




       self.create_and_test_config_common_properties()
       self.config_tester.create_and_test_config_to_json_string()
       self.config_tester.create_and_test_config_to_json_file()
       self.config_tester.create_and_test_config_from_and_save_pretrained()
       self.config_tester.create_and_test_config_with_num_labels()
       self.config_tester.check_config_can_be_init_without_params()
       self.config_tester.check_config_arguments_init()







   def 					lowerCamelCase						(      self		)      ->						Dict:

       '''simple docstring'''




       return







   @unittest.skip(reason="Cvt does not output attentions"		)
   def 					lowerCamelCase						(      self		)      ->						int:

       '''simple docstring'''




       pass







   @unittest.skip(reason="Cvt does not use inputs_embeds"		)
   def 					lowerCamelCase						(      self		)      ->						Optional[int]:

       '''simple docstring'''




       pass







   @unittest.skip(reason="Cvt does not support input and output embeddings"		)
   def 					lowerCamelCase						(      self		)      ->						Optional[int]:

       '''simple docstring'''




       pass







   def 					lowerCamelCase						(      self		)      ->						str:

       '''simple docstring'''




       snake_case   ,snake_case       : Optional[int]    =       self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
           snake_case       : Any    =       model_class(UpperCamelCase__		)
           snake_case       : List[str]    =       inspect.signature(model.forward		)
           # signature.parameters is an OrderedDict => so arg_names order is deterministic
           snake_case       : Any    =       [*signature.parameters.keys()]

           snake_case       : Optional[int]    =       ["pixel_values"]
           self.assertListEqual(arg_names[:1]		,      UpperCamelCase__		)







   def 					lowerCamelCase						(      self		)      ->						List[Any]:

       '''simple docstring'''




       snake_case       : Any    =       self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*UpperCamelCase__		)







   def 					lowerCamelCase						(      self		)      ->						Tuple:

       '''simple docstring'''




       def check_hidden_states_output(UpperCamelCase__		,      UpperCamelCase__		,      UpperCamelCase__		):
           snake_case       : List[Any]    =       model_class(UpperCamelCase__		)
           model.to(UpperCamelCase__		)
           model.eval()

           with torch.no_grad():
               snake_case       : List[Any]    =       model(**self._prepare_for_class(UpperCamelCase__		,      UpperCamelCase__		)		)

           snake_case       : Union[str, Any]    =       outputs.hidden_states

           snake_case       : Optional[int]    =       len(self.model_tester.depth		)
           self.assertEqual(len(UpperCamelCase__		)		,      UpperCamelCase__		)

           # verify the first hidden states (first block)
           self.assertListEqual(
               list(hidden_states[0].shape[-3:]		)		,      [
                   self.model_tester.embed_dim[0],
                   self.model_tester.image_size // 4,
                   self.model_tester.image_size // 4,
               ]		,      )

       snake_case   ,snake_case       : int    =       self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
           snake_case       : Dict    =       True
           check_hidden_states_output(UpperCamelCase__		,      UpperCamelCase__		,      UpperCamelCase__		)

           # check that output_hidden_states also work using config
           del inputs_dict["output_hidden_states"]
           snake_case       : List[Any]    =       True

           check_hidden_states_output(UpperCamelCase__		,      UpperCamelCase__		,      UpperCamelCase__		)







   def 					lowerCamelCase						(      self		)      ->						List[Any]:

       '''simple docstring'''




       snake_case       : Dict    =       self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*UpperCamelCase__		)







   @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."		)
   def 					lowerCamelCase						(      self		)      ->						Optional[int]:

       '''simple docstring'''




       pass







   @slow
   def 					lowerCamelCase						(      self		)      ->						Union[str, Any]:

       '''simple docstring'''




       for model_name in CVT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           snake_case       : List[Any]    =       CvtModel.from_pretrained(UpperCamelCase__		)
           self.assertIsNotNone(UpperCamelCase__		)







def     __lowerCAmelCase		(		)      ->		List[str]:


    """simple docstring"""





    snake_case       : List[Any]    =       Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"					)
    return image







@require_torch
@require_vision
class _lowerCAmelCase							( unittest.TestCase      ):







   @cached_property
   def 					lowerCamelCase						(      self		)      ->						Dict:

       '''simple docstring'''




       return AutoImageProcessor.from_pretrained(CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]		)







   @slow
   def 					lowerCamelCase						(      self		)      ->						List[Any]:

       '''simple docstring'''




       snake_case       : Dict    =       CvtForImageClassification.from_pretrained(CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]		).to(UpperCamelCase__		)

       snake_case       : Union[str, Any]    =       self.default_image_processor
       snake_case       : Any    =       prepare_img()
       snake_case       : Tuple    =       image_processor(images=UpperCamelCase__		,      return_tensors="pt"		).to(UpperCamelCase__		)

       # forward pass
       with torch.no_grad():
           snake_case       : Tuple    =       model(**UpperCamelCase__		)

       # verify the logits
       snake_case       : List[str]    =       torch.Size((1, 1000)		)
       self.assertEqual(outputs.logits.shape		,      UpperCamelCase__		)

       snake_case       : Tuple    =       torch.tensor([0.9285, 0.9015, -0.3150]		).to(UpperCamelCase__		)

       self.assertTrue(torch.allclose(outputs.logits[0, :3]		,      UpperCamelCase__		,      atol=1e-4		)		)









"""simple docstring"""



import os
import sys
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path

from huggingface_hub import HfFolder, delete_repo
from huggingface_hub.file_download import http_get
from requests.exceptions import HTTPError

from transformers import (
    AlbertTokenizer,
    AutoTokenizer,
    BertTokenizer,
    BertTokenizerFast,
    GPTaTokenizerFast,
    is_tokenizers_available,
)
from transformers.testing_utils import TOKEN, USER, is_staging_test, require_tokenizers
from transformers.tokenization_utils import Trie


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

from test_module.custom_tokenization import CustomTokenizer  # noqa E402


if is_tokenizers_available():
  from test_module.custom_tokenization_fast import CustomTokenizerFast







class _lowerCAmelCase							( unittest.TestCase      ):







   def 					lowerCamelCase						(      self		)      ->						str:

       '''simple docstring'''




       snake_case       : List[str]    =       mock.Mock()
       snake_case       : Any    =       500
       snake_case       : int    =       {}
       snake_case       : int    =       HTTPError
       snake_case       : Dict    =       {}

       # Download this model to make sure it's in the cache.
       snake_case       : Dict    =       BertTokenizer.from_pretrained("hf-internal-testing/tiny-random-bert"		)

       # Under the mock environment we get a 500 error when trying to reach the tokenizer.
       with mock.patch("requests.Session.request"		,      return_value=UpperCamelCase__		) as mock_head:
           snake_case       : str    =       BertTokenizer.from_pretrained("hf-internal-testing/tiny-random-bert"		)
           # This check we did call the fake head request
           mock_head.assert_called()







   @require_tokenizers
   def 					lowerCamelCase						(      self		)      ->						int:

       '''simple docstring'''




       snake_case       : Union[str, Any]    =       mock.Mock()
       snake_case       : int    =       500
       snake_case       : Optional[int]    =       {}
       snake_case       : int    =       HTTPError
       snake_case       : int    =       {}

       # Download this model to make sure it's in the cache.
       snake_case       : Any    =       GPTaTokenizerFast.from_pretrained("gpt2"		)

       # Under the mock environment we get a 500 error when trying to reach the tokenizer.
       with mock.patch("requests.Session.request"		,      return_value=UpperCamelCase__		) as mock_head:
           snake_case       : Tuple    =       GPTaTokenizerFast.from_pretrained("gpt2"		)
           # This check we did call the fake head request
           mock_head.assert_called()







   def 					lowerCamelCase						(      self		)      ->						List[str]:

       '''simple docstring'''




       try:
           snake_case       : Tuple    =       tempfile.mktemp()
           with open(UpperCamelCase__		,      "wb"		) as f:
               http_get("https://huggingface.co/albert-base-v1/resolve/main/spiece.model"		,      UpperCamelCase__		)

           snake_case       : List[str]    =       AlbertTokenizer.from_pretrained(UpperCamelCase__		)
       finally:
           os.remove(UpperCamelCase__		)

       # Supporting this legacy load introduced a weird bug where the tokenizer would load local files if they are in
       # the current folder and have the right name.
       if os.path.isfile("tokenizer.json"		):
           # We skip the test if the user has a `tokenizer.json` in this folder to avoid deleting it.
           return
       try:
           with open("tokenizer.json"		,      "wb"		) as f:
               http_get("https://huggingface.co/hf-internal-testing/tiny-random-bert/blob/main/tokenizer.json"		,      UpperCamelCase__		)
           snake_case       : Dict    =       AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-gpt2"		)
           # The tiny random BERT has a vocab size of 1024, tiny gpt2 as a vocab size of 1000
           self.assertEqual(tokenizer.vocab_size		,      1000		)
           # Tokenizer should depend on the remote checkpoint, not the local tokenizer.json file.

       finally:
           os.remove("tokenizer.json"		)







   def 					lowerCamelCase						(      self		)      ->						Optional[Any]:

       '''simple docstring'''




       snake_case       : int    =       AlbertTokenizer.from_pretrained("https://huggingface.co/albert-base-v1/resolve/main/spiece.model"		)







@is_staging_test
class _lowerCAmelCase							( unittest.TestCase      ):
   __UpperCAmelCase					:			Dict				    =    ['''[UNK]''', '''[CLS]''', '''[SEP]''', '''[PAD]''', '''[MASK]''', '''bla''', '''blou''']







   @classmethod
   def 					lowerCamelCase						(      cls		)      ->						Optional[int]:

       '''simple docstring'''




       snake_case       : List[str]    =       TOKEN
       HfFolder.save_token(UpperCamelCase__		)







   @classmethod
   def 					lowerCamelCase						(      cls		)      ->						Union[str, Any]:

       '''simple docstring'''




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

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

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







   def 					lowerCamelCase						(      self		)      ->						Dict:

       '''simple docstring'''




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

       tokenizer.push_to_hub("test-tokenizer"		,      use_auth_token=self._token		)
       snake_case       : Dict    =       BertTokenizer.from_pretrained(F'{USER}/test-tokenizer'		)
       self.assertDictEqual(new_tokenizer.vocab		,      tokenizer.vocab		)

       # Reset repo
       delete_repo(token=self._token		,      repo_id="test-tokenizer"		)

       # Push to hub via save_pretrained
       with tempfile.TemporaryDirectory() as tmp_dir:
           tokenizer.save_pretrained(UpperCamelCase__		,      repo_id="test-tokenizer"		,      push_to_hub=UpperCamelCase__		,      use_auth_token=self._token		)

       snake_case       : Dict    =       BertTokenizer.from_pretrained(F'{USER}/test-tokenizer'		)
       self.assertDictEqual(new_tokenizer.vocab		,      tokenizer.vocab		)







   def 					lowerCamelCase						(      self		)      ->						Any:

       '''simple docstring'''




       with tempfile.TemporaryDirectory() as tmp_dir:
           snake_case       : Dict    =       os.path.join(UpperCamelCase__		,      "vocab.txt"		)
           with open(UpperCamelCase__		,      "w"		,      encoding="utf-8"		) as vocab_writer:
               vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]		)		)
           snake_case       : Optional[int]    =       BertTokenizer(UpperCamelCase__		)

       tokenizer.push_to_hub("valid_org/test-tokenizer-org"		,      use_auth_token=self._token		)
       snake_case       : Dict    =       BertTokenizer.from_pretrained("valid_org/test-tokenizer-org"		)
       self.assertDictEqual(new_tokenizer.vocab		,      tokenizer.vocab		)

       # Reset repo
       delete_repo(token=self._token		,      repo_id="valid_org/test-tokenizer-org"		)

       # Push to hub via save_pretrained
       with tempfile.TemporaryDirectory() as tmp_dir:
           tokenizer.save_pretrained(
               UpperCamelCase__		,      repo_id="valid_org/test-tokenizer-org"		,      push_to_hub=UpperCamelCase__		,      use_auth_token=self._token		)

       snake_case       : Optional[int]    =       BertTokenizer.from_pretrained("valid_org/test-tokenizer-org"		)
       self.assertDictEqual(new_tokenizer.vocab		,      tokenizer.vocab		)







   @require_tokenizers
   def 					lowerCamelCase						(      self		)      ->						Union[str, Any]:

       '''simple docstring'''




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

       # No fast custom tokenizer
       tokenizer.push_to_hub("test-dynamic-tokenizer"		,      use_auth_token=self._token		)

       snake_case       : Union[str, Any]    =       AutoTokenizer.from_pretrained(F'{USER}/test-dynamic-tokenizer'		,      trust_remote_code=UpperCamelCase__		)
       # Can't make an isinstance check because the new_model.config is from the CustomTokenizer class of a dynamic module
       self.assertEqual(tokenizer.__class__.__name__		,      "CustomTokenizer"		)

       # Fast and slow custom tokenizer
       CustomTokenizerFast.register_for_auto_class()
       with tempfile.TemporaryDirectory() as tmp_dir:
           snake_case       : int    =       os.path.join(UpperCamelCase__		,      "vocab.txt"		)
           with open(UpperCamelCase__		,      "w"		,      encoding="utf-8"		) as vocab_writer:
               vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]		)		)

           snake_case       : Optional[Any]    =       BertTokenizerFast.from_pretrained(UpperCamelCase__		)
           bert_tokenizer.save_pretrained(UpperCamelCase__		)
           snake_case       : List[Any]    =       CustomTokenizerFast.from_pretrained(UpperCamelCase__		)

       tokenizer.push_to_hub("test-dynamic-tokenizer"		,      use_auth_token=self._token		)

       snake_case       : Union[str, Any]    =       AutoTokenizer.from_pretrained(F'{USER}/test-dynamic-tokenizer'		,      trust_remote_code=UpperCamelCase__		)
       # Can't make an isinstance check because the new_model.config is from the FakeConfig class of a dynamic module
       self.assertEqual(tokenizer.__class__.__name__		,      "CustomTokenizerFast"		)
       snake_case       : Optional[Any]    =       AutoTokenizer.from_pretrained(
           F'{USER}/test-dynamic-tokenizer'		,      use_fast=UpperCamelCase__		,      trust_remote_code=UpperCamelCase__		)
       # Can't make an isinstance check because the new_model.config is from the FakeConfig class of a dynamic module
       self.assertEqual(tokenizer.__class__.__name__		,      "CustomTokenizer"		)







class _lowerCAmelCase							( unittest.TestCase      ):







   def 					lowerCamelCase						(      self		)      ->						str:

       '''simple docstring'''




       snake_case       : Any    =       Trie()
       trie.add("Hello 友達"		)
       self.assertEqual(trie.data		,      {"H": {"e": {"l": {"l": {"o": {" ": {"友": {"達": {"": 1}}}}}}}}}		)
       trie.add("Hello"		)
       trie.data
       self.assertEqual(trie.data		,      {"H": {"e": {"l": {"l": {"o": {"": 1, " ": {"友": {"達": {"": 1}}}}}}}}}		)







   def 					lowerCamelCase						(      self		)      ->						Any:

       '''simple docstring'''




       snake_case       : Tuple    =       Trie()
       self.assertEqual(trie.split("[CLS] This is a extra_id_100"		)		,      ["[CLS] This is a extra_id_100"]		)
       trie.add("[CLS]"		)
       trie.add("extra_id_1"		)
       trie.add("extra_id_100"		)
       self.assertEqual(trie.split("[CLS] This is a extra_id_100"		)		,      ["[CLS]", " This is a ", "extra_id_100"]		)







   def 					lowerCamelCase						(      self		)      ->						List[str]:

       '''simple docstring'''




       snake_case       : str    =       Trie()
       trie.add("A"		)
       self.assertEqual(trie.split("ABC"		)		,      ["A", "BC"]		)
       self.assertEqual(trie.split("BCA"		)		,      ["BC", "A"]		)







   def 					lowerCamelCase						(      self		)      ->						int:

       '''simple docstring'''




       snake_case       : Union[str, Any]    =       Trie()
       trie.add("TOKEN]"		)
       trie.add("[SPECIAL_TOKEN]"		)
       self.assertEqual(trie.split("This is something [SPECIAL_TOKEN]"		)		,      ["This is something ", "[SPECIAL_TOKEN]"]		)







   def 					lowerCamelCase						(      self		)      ->						Tuple:

       '''simple docstring'''




       snake_case       : Optional[int]    =       Trie()
       trie.add("A"		)
       trie.add("P"		)
       trie.add("[SPECIAL_TOKEN]"		)
       self.assertEqual(trie.split("This is something [SPECIAL_TOKEN]"		)		,      ["This is something ", "[SPECIAL_TOKEN]"]		)







   def 					lowerCamelCase						(      self		)      ->						List[str]:

       '''simple docstring'''




       snake_case       : List[Any]    =       Trie()
       trie.add("AB"		)
       trie.add("B"		)
       trie.add("C"		)
       self.assertEqual(trie.split("ABC"		)		,      ["AB", "C"]		)







   def 					lowerCamelCase						(      self		)      ->						Dict:

       '''simple docstring'''




       snake_case       : str    =       Trie()
       trie.add("ABC"		)
       trie.add("B"		)
       trie.add("CD"		)
       self.assertEqual(trie.split("ABCD"		)		,      ["ABC", "D"]		)







   def 					lowerCamelCase						(      self		)      ->						Optional[Any]:

       '''simple docstring'''




       snake_case       : Optional[int]    =       Trie()
       snake_case       : Union[str, Any]    =       trie.cut_text("ABC"		,      [0, 0, 2, 1, 2, 3]		)
       self.assertEqual(UpperCamelCase__		,      ["AB", "C"]		)





