



import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import cached_download, hf_hub_url
from PIL import Image

from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor
from transformers.utils import logging


logging.set_verbosity_info()
a_						:     Any	     =		logging.get_logger(__name__)

def     __lowercase(	UpperCAmelCase__ ):


      """simple docstring"""



      lowerCamelCase								=		DPTConfig()

      if "large" in checkpoint_url:
            lowerCamelCase								=		1024
            lowerCamelCase								=		4096
            lowerCamelCase								=		24
            lowerCamelCase								=		16
            lowerCamelCase								=		[5, 11, 17, 23]
            lowerCamelCase								=		[256, 512, 1024, 1024]
            lowerCamelCase								=		(1, 384, 384)

      if "ade" in checkpoint_url:
            lowerCamelCase								=		True

            lowerCamelCase								=		150
            lowerCamelCase								=		"huggingface/label-files"
            lowerCamelCase								=		"ade20k-id2label.json"
            lowerCamelCase								=		json.load(open(cached_download(hf_hub_url(UpperCAmelCase__   ,   UpperCAmelCase__   ,   repo_type="dataset" ) )   ,   "r" ) )
            lowerCamelCase								=		{int(UpperCAmelCase__ ): v for k, v in idalabel.items()}
            lowerCamelCase								=		idalabel
            lowerCamelCase								=		{v: k for k, v in idalabel.items()}
            lowerCamelCase								=		[1, 150, 480, 480]

      return config, expected_shape

def     __lowercase(	UpperCAmelCase__ ):


      """simple docstring"""



      lowerCamelCase								=		["pretrained.model.head.weight", "pretrained.model.head.bias"]
      for k in ignore_keys:
            state_dict.pop(UpperCAmelCase__   ,   UpperCAmelCase__ )

def     __lowercase(	UpperCAmelCase__ ):


      """simple docstring"""



      if (
          "pretrained.model" in name
          and "cls_token" not in name
          and "pos_embed" not in name
          and "patch_embed" not in name
      ):
            lowerCamelCase								=		name.replace("pretrained.model"   ,   "dpt.encoder" )
      if "pretrained.model" in name:
            lowerCamelCase								=		name.replace("pretrained.model"   ,   "dpt.embeddings" )
      if "patch_embed" in name:
            lowerCamelCase								=		name.replace("patch_embed"   ,   "patch_embeddings" )
      if "pos_embed" in name:
            lowerCamelCase								=		name.replace("pos_embed"   ,   "position_embeddings" )
      if "attn.proj" in name:
            lowerCamelCase								=		name.replace("attn.proj"   ,   "attention.output.dense" )
      if "proj" in name and "project" not in name:
            lowerCamelCase								=		name.replace("proj"   ,   "projection" )
      if "blocks" in name:
            lowerCamelCase								=		name.replace("blocks"   ,   "layer" )
      if "mlp.fc1" in name:
            lowerCamelCase								=		name.replace("mlp.fc1"   ,   "intermediate.dense" )
      if "mlp.fc2" in name:
            lowerCamelCase								=		name.replace("mlp.fc2"   ,   "output.dense" )
      if "norm1" in name:
            lowerCamelCase								=		name.replace("norm1"   ,   "layernorm_before" )
      if "norm2" in name:
            lowerCamelCase								=		name.replace("norm2"   ,   "layernorm_after" )
      if "scratch.output_conv" in name:
            lowerCamelCase								=		name.replace("scratch.output_conv"   ,   "head" )
      if "scratch" in name:
            lowerCamelCase								=		name.replace("scratch"   ,   "neck" )
      if "layer1_rn" in name:
            lowerCamelCase								=		name.replace("layer1_rn"   ,   "convs.0" )
      if "layer2_rn" in name:
            lowerCamelCase								=		name.replace("layer2_rn"   ,   "convs.1" )
      if "layer3_rn" in name:
            lowerCamelCase								=		name.replace("layer3_rn"   ,   "convs.2" )
      if "layer4_rn" in name:
            lowerCamelCase								=		name.replace("layer4_rn"   ,   "convs.3" )
      if "refinenet" in name:
            lowerCamelCase								=		int(name[len("neck.refinenet" ) : len("neck.refinenet" ) + 1] )
            # tricky here: we need to map 4 to 0, 3 to 1, 2 to 2 and 1 to 3
            lowerCamelCase								=		name.replace(F"""refinenet{layer_idx}"""   ,   F"""fusion_stage.layers.{abs(layer_idx-4 )}""" )
      if "out_conv" in name:
            lowerCamelCase								=		name.replace("out_conv"   ,   "projection" )
      if "resConfUnit1" in name:
            lowerCamelCase								=		name.replace("resConfUnit1"   ,   "residual_layer1" )
      if "resConfUnit2" in name:
            lowerCamelCase								=		name.replace("resConfUnit2"   ,   "residual_layer2" )
      if "conv1" in name:
            lowerCamelCase								=		name.replace("conv1"   ,   "convolution1" )
      if "conv2" in name:
            lowerCamelCase								=		name.replace("conv2"   ,   "convolution2" )
      # readout blocks
      if "pretrained.act_postprocess1.0.project.0" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess1.0.project.0"   ,   "neck.reassemble_stage.readout_projects.0.0" )
      if "pretrained.act_postprocess2.0.project.0" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess2.0.project.0"   ,   "neck.reassemble_stage.readout_projects.1.0" )
      if "pretrained.act_postprocess3.0.project.0" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess3.0.project.0"   ,   "neck.reassemble_stage.readout_projects.2.0" )
      if "pretrained.act_postprocess4.0.project.0" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess4.0.project.0"   ,   "neck.reassemble_stage.readout_projects.3.0" )
      # resize blocks
      if "pretrained.act_postprocess1.3" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess1.3"   ,   "neck.reassemble_stage.layers.0.projection" )
      if "pretrained.act_postprocess1.4" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess1.4"   ,   "neck.reassemble_stage.layers.0.resize" )
      if "pretrained.act_postprocess2.3" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess2.3"   ,   "neck.reassemble_stage.layers.1.projection" )
      if "pretrained.act_postprocess2.4" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess2.4"   ,   "neck.reassemble_stage.layers.1.resize" )
      if "pretrained.act_postprocess3.3" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess3.3"   ,   "neck.reassemble_stage.layers.2.projection" )
      if "pretrained.act_postprocess4.3" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess4.3"   ,   "neck.reassemble_stage.layers.3.projection" )
      if "pretrained.act_postprocess4.4" in name:
            lowerCamelCase								=		name.replace("pretrained.act_postprocess4.4"   ,   "neck.reassemble_stage.layers.3.resize" )
      if "pretrained" in name:
            lowerCamelCase								=		name.replace("pretrained"   ,   "dpt" )
      if "bn" in name:
            lowerCamelCase								=		name.replace("bn"   ,   "batch_norm" )
      if "head" in name:
            lowerCamelCase								=		name.replace("head"   ,   "head.head" )
      if "encoder.norm" in name:
            lowerCamelCase								=		name.replace("encoder.norm"   ,   "layernorm" )
      if "auxlayer" in name:
            lowerCamelCase								=		name.replace("auxlayer"   ,   "auxiliary_head.head" )

      return name

def     __lowercase(	UpperCAmelCase__   ,   UpperCAmelCase__ ):


      """simple docstring"""



      for i in range(config.num_hidden_layers ):
            # read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
            lowerCamelCase								=		state_dict.pop(F"""dpt.encoder.layer.{i}.attn.qkv.weight""" )
            lowerCamelCase								=		state_dict.pop(F"""dpt.encoder.layer.{i}.attn.qkv.bias""" )
            # next, add query, keys and values (in that order) to the state dict
            lowerCamelCase								=		in_proj_weight[: config.hidden_size, :]
            lowerCamelCase								=		in_proj_bias[: config.hidden_size]
            lowerCamelCase								=		in_proj_weight[
                config.hidden_size : config.hidden_size * 2, :
            ]
            lowerCamelCase								=		in_proj_bias[
                config.hidden_size : config.hidden_size * 2
            ]
            lowerCamelCase								=		in_proj_weight[
                -config.hidden_size :, :
            ]
            lowerCamelCase								=		in_proj_bias[-config.hidden_size :]

def     __lowercase(	):


      """simple docstring"""



      lowerCamelCase								=		"http://images.cocodataset.org/val2017/000000039769.jpg"
      lowerCamelCase								=		Image.open(requests.get(UpperCAmelCase__   ,   stream=UpperCAmelCase__ ).raw )
      return im

@torch.no_grad()
def     __lowercase(	UpperCAmelCase__   ,   UpperCAmelCase__   ,   UpperCAmelCase__   ,   UpperCAmelCase__ ):


      """simple docstring"""



      lowerCamelCase			,							lowerCamelCase								=		get_dpt_config(UpperCAmelCase__ )
      # load original state_dict from URL
      lowerCamelCase								=		torch.hub.load_state_dict_from_url(UpperCAmelCase__   ,   map_location="cpu" )
      # remove certain keys
      remove_ignore_keys_(UpperCAmelCase__ )
      # rename keys
      for key in state_dict.copy().keys():
            lowerCamelCase								=		state_dict.pop(UpperCAmelCase__ )
            lowerCamelCase								=		val
      # read in qkv matrices
      read_in_q_k_v(UpperCAmelCase__   ,   UpperCAmelCase__ )

      # load HuggingFace model
      lowerCamelCase								=		DPTForSemanticSegmentation(UpperCAmelCase__ ) if "ade" in checkpoint_url else DPTForDepthEstimation(UpperCAmelCase__ )
      model.load_state_dict(UpperCAmelCase__ )
      model.eval()

      # Check outputs on an image
      lowerCamelCase								=		480 if "ade" in checkpoint_url else 384
      lowerCamelCase								=		DPTImageProcessor(size=UpperCAmelCase__ )

      lowerCamelCase								=		prepare_img()
      lowerCamelCase								=		image_processor(UpperCAmelCase__   ,   return_tensors="pt" )

      # forward pass
      lowerCamelCase								=		model(**UpperCAmelCase__ ).logits if "ade" in checkpoint_url else model(**UpperCAmelCase__ ).predicted_depth

      # Assert logits
      lowerCamelCase								=		torch.tensor([[6.3_1_9_9, 6.3_6_2_9, 6.4_1_4_8], [6.3_8_5_0, 6.3_6_1_5, 6.4_1_6_6], [6.3_5_1_9, 6.3_1_7_6, 6.3_5_7_5]] )
      if "ade" in checkpoint_url:
            lowerCamelCase								=		torch.tensor([[4.0_4_8_0, 4.2_4_2_0, 4.4_3_6_0], [4.3_1_2_4, 4.5_6_9_3, 4.8_2_6_1], [4.5_7_6_8, 4.8_9_6_5, 5.2_1_6_3]] )
      assert outputs.shape == torch.Size(UpperCAmelCase__ )
      assert (
          torch.allclose(outputs[0, 0, :3, :3]   ,   UpperCAmelCase__   ,   atol=1E-4 )
          if "ade" in checkpoint_url
          else torch.allclose(outputs[0, :3, :3]   ,   UpperCAmelCase__ )
      )

      Path(UpperCAmelCase__ ).mkdir(exist_ok=UpperCAmelCase__ )
      print(F"""Saving model to {pytorch_dump_folder_path}""" )
      model.save_pretrained(UpperCAmelCase__ )
      print(F"""Saving image processor to {pytorch_dump_folder_path}""" )
      image_processor.save_pretrained(UpperCAmelCase__ )

      if push_to_hub:
            print("Pushing model to hub..." )
            model.push_to_hub(
                repo_path_or_name=Path(UpperCAmelCase__   ,   UpperCAmelCase__ )   ,   organization="nielsr"   ,   commit_message="Add model"   ,   use_temp_dir=UpperCAmelCase__   ,   )
            image_processor.push_to_hub(
                repo_path_or_name=Path(UpperCAmelCase__   ,   UpperCAmelCase__ )   ,   organization="nielsr"   ,   commit_message="Add image processor"   ,   use_temp_dir=UpperCAmelCase__   ,   )


if __name__ == "__main__":
     a_						:     Dict	     =		argparse.ArgumentParser()
     # Required parameters
     parser.add_argument(
         '--checkpoint_url',
         default='https://github.com/intel-isl/DPT/releases/download/1_0/dpt_large-midas-2f21e586.pt',
         type=str,
         help='URL of the original DPT checkpoint you\'d like to convert.',
     )
     parser.add_argument(
         '--pytorch_dump_folder_path',
         default=None,
         type=str,
         required=True,
         help='Path to the output PyTorch model directory.',
     )
     parser.add_argument(
         '--push_to_hub',
         action='store_true',
     )
     parser.add_argument(
         '--model_name',
         default='dpt-large',
         type=str,
         help='Name of the model, in case you\'re pushing to the hub.',
     )

     a_						:     Dict	     =		parser.parse_args()
     convert_dpt_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path, args.push_to_hub, args.model_name)




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):
     """simple docstring"""



     def 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		mock.Mock()
           lowerCamelCase								=		5_00
           lowerCamelCase								=		{}
           lowerCamelCase								=		HTTPError
           lowerCamelCase								=		{}

           # Download this model to make sure it's in the cache.
           lowerCamelCase								=		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=__a    ) as mock_head:
                 lowerCamelCase								=		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 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		mock.Mock()
           lowerCamelCase								=		5_00
           lowerCamelCase								=		{}
           lowerCamelCase								=		HTTPError
           lowerCamelCase								=		{}

           # Download this model to make sure it's in the cache.
           lowerCamelCase								=		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=__a    ) as mock_head:
                 lowerCamelCase								=		GPTaTokenizerFast.from_pretrained("gpt2"    )
                 # This check we did call the fake head request
                 mock_head.assert_called()







     def 						_a      (self    ):






           '''simple docstring'''



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

                 lowerCamelCase								=		AlbertTokenizer.from_pretrained(__a    )
           finally:
                 os.remove(__a    )

           # 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"				,			__a    )
                 lowerCamelCase								=		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				,			10_00    )
                 # Tokenizer should depend on the remote checkpoint, not the local tokenizer.json file.

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







     def 						_a      (self    ):






           '''simple docstring'''



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





@is_staging_test
class    lowerCamelCase__  (						unittest.TestCase):
     """simple docstring"""



     _A       =			['[UNK]', '[CLS]', '[SEP]', '[PAD]', '[MASK]', 'bla', 'blou']







     @classmethod
     def 						_a      (cls    ):






           '''simple docstring'''



           lowerCamelCase								=		TOKEN
           HfFolder.save_token(__a    )







     @classmethod
     def 						_a      (cls    ):






           '''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 						_a      (self    ):






           '''simple docstring'''



           with tempfile.TemporaryDirectory() as tmp_dir:
                 lowerCamelCase								=		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]    )    )
                 lowerCamelCase								=		BertTokenizer(__a    )

           tokenizer.push_to_hub("test-tokenizer"				,			use_auth_token=self._token    )
           lowerCamelCase								=		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(__a				,			repo_id="test-tokenizer"				,			push_to_hub=__a				,			use_auth_token=self._token    )

           lowerCamelCase								=		BertTokenizer.from_pretrained(F"""{USER}/test-tokenizer"""    )
           self.assertDictEqual(new_tokenizer.vocab				,			tokenizer.vocab    )







     def 						_a      (self    ):






           '''simple docstring'''



           with tempfile.TemporaryDirectory() as tmp_dir:
                 lowerCamelCase								=		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]    )    )
                 lowerCamelCase								=		BertTokenizer(__a    )

           tokenizer.push_to_hub("valid_org/test-tokenizer-org"				,			use_auth_token=self._token    )
           lowerCamelCase								=		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(
                     __a				,			repo_id="valid_org/test-tokenizer-org"				,			push_to_hub=__a				,			use_auth_token=self._token    )

           lowerCamelCase								=		BertTokenizer.from_pretrained("valid_org/test-tokenizer-org"    )
           self.assertDictEqual(new_tokenizer.vocab				,			tokenizer.vocab    )







     @require_tokenizers
     def 						_a      (self    ):






           '''simple docstring'''



           CustomTokenizer.register_for_auto_class()
           with tempfile.TemporaryDirectory() as tmp_dir:
                 lowerCamelCase								=		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]    )    )
                 lowerCamelCase								=		CustomTokenizer(__a    )

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

           lowerCamelCase								=		AutoTokenizer.from_pretrained(F"""{USER}/test-dynamic-tokenizer"""				,			trust_remote_code=__a    )
           # 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:
                 lowerCamelCase								=		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]    )    )

                 lowerCamelCase								=		BertTokenizerFast.from_pretrained(__a    )
                 bert_tokenizer.save_pretrained(__a    )
                 lowerCamelCase								=		CustomTokenizerFast.from_pretrained(__a    )

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

           lowerCamelCase								=		AutoTokenizer.from_pretrained(F"""{USER}/test-dynamic-tokenizer"""				,			trust_remote_code=__a    )
           # 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"    )
           lowerCamelCase								=		AutoTokenizer.from_pretrained(
               F"""{USER}/test-dynamic-tokenizer"""				,			use_fast=__a				,			trust_remote_code=__a    )
           # 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):
     """simple docstring"""



     def 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		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 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		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 						_a      (self    ):






           '''simple docstring'''



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







     def 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		Trie()
           trie.add("TOKEN]"    )
           trie.add("[SPECIAL_TOKEN]"    )
           self.assertEqual(trie.split("This is something [SPECIAL_TOKEN]"    )				,			["This is something ", "[SPECIAL_TOKEN]"]    )







     def 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		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 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		Trie()
           trie.add("AB"    )
           trie.add("B"    )
           trie.add("C"    )
           self.assertEqual(trie.split("ABC"    )				,			["AB", "C"]    )







     def 						_a      (self    ):






           '''simple docstring'''



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







     def 						_a      (self    ):






           '''simple docstring'''



           lowerCamelCase								=		Trie()
           lowerCamelCase								=		trie.cut_text("ABC"				,			[0, 0, 2, 1, 2, 3]    )
           self.assertEqual(__a				,			["AB", "C"]    )