
"""simple docstring"""




# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/

import gc
import random
import tempfile
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    ControlNetModel,
    DDIMScheduler,
    StableDiffusionControlNetImgaImgPipeline,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import MultiControlNetModel
from diffusers.utils import floats_tensor, load_image, load_numpy, randn_tensor, slow, torch_device
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import (
    PipelineKarrasSchedulerTesterMixin,
    PipelineLatentTesterMixin,
    PipelineTesterMixin,
)


enable_full_determinism()

class 		a__						(      a_,			a_,			a_,			unittest.TestCase						):
   __lowerCAmelCase            =				StableDiffusionControlNetImgaImgPipeline
   __lowerCAmelCase            =				TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"""height""", """width"""}
   __lowerCAmelCase            =				TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
   __lowerCAmelCase            =				IMAGE_TO_IMAGE_IMAGE_PARAMS.union({"""control_image"""}						)
   __lowerCAmelCase            =				IMAGE_TO_IMAGE_IMAGE_PARAMS
   def 			__magic_name__			(			self				):
          torch.manual_seed(0				)
          lowercase    :				str       		=							UNetaDConditionModel(
              block_out_channels=(32, 64)	,    layers_per_block=2	,    sample_size=32	,    in_channels=4	,    out_channels=4	,    down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")	,    up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")	,    cross_attention_dim=32	,    )
          torch.manual_seed(0				)
          lowercase    :				str       		=							ControlNetModel(
              block_out_channels=(32, 64)	,    layers_per_block=2	,    in_channels=4	,    down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")	,    cross_attention_dim=32	,    conditioning_embedding_out_channels=(16, 32)	,    )
          torch.manual_seed(0				)
          lowercase    :				Union[str, Any]       		=							DDIMScheduler(
              beta_start=0.0_0_0_8_5	,    beta_end=0.0_1_2	,    beta_schedule="scaled_linear"	,    clip_sample=_a	,    set_alpha_to_one=_a	,    )
          torch.manual_seed(0				)
          lowercase    :				Union[str, Any]       		=							AutoencoderKL(
              block_out_channels=[32, 64]	,    in_channels=3	,    out_channels=3	,    down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]	,    up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]	,    latent_channels=4	,    )
          torch.manual_seed(0				)
          lowercase    :				List[str]       		=							CLIPTextConfig(
              bos_token_id=0	,    eos_token_id=2	,    hidden_size=32	,    intermediate_size=37	,    layer_norm_eps=1E-05	,    num_attention_heads=4	,    num_hidden_layers=5	,    pad_token_id=1	,    vocab_size=1_000	,    )
          lowercase    :				Optional[int]       		=							CLIPTextModel(_a				)
          lowercase    :				Optional[int]       		=							CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"				)

          lowercase    :				Tuple       		=							{
              "unet": unet,
              "controlnet": controlnet,
              "scheduler": scheduler,
              "vae": vae,
              "text_encoder": text_encoder,
              "tokenizer": tokenizer,
              "safety_checker": None,
              "feature_extractor": None,
          }
          return components
   def 			__magic_name__			(			self	,    _a	,    _a=0				):
          if str(_a				).startswith("mps"				):
                 lowercase    :				Union[str, Any]       		=							torch.manual_seed(_a				)
          else:
                 lowercase    :				int       		=							torch.Generator(device=_a				).manual_seed(_a				)

          lowercase    :				List[str]       		=							2
          lowercase    :				List[str]       		=							randn_tensor(
              (1, 3, 32 * controlnet_embedder_scale_factor, 32 * controlnet_embedder_scale_factor)	,    generator=_a	,    device=torch.device(_a				)	,    )
          lowercase    :				str       		=							floats_tensor(control_image.shape	,    rng=random.Random(_a				)				).to(_a				)
          lowercase    :				List[str]       		=							image.cpu().permute(0	,    2	,    3	,    1				)[0]
          lowercase    :				str       		=							Image.fromarray(np.uinta(_a				)				).convert("RGB"				).resize((64, 64)				)
          lowercase    :				str       		=							{
              "prompt": "A painting of a squirrel eating a burger",
              "generator": generator,
              "num_inference_steps": 2,
              "guidance_scale": 6.0,
              "output_type": "numpy",
              "image": image,
              "control_image": control_image,
          }

          return inputs
   def 			__magic_name__			(			self				):
          return self._test_attention_slicing_forward_pass(expected_max_diff=2E-3				)
   @unittest.skipIf(
       torch_device != "cuda" or not is_xformers_available()	,    reason="XFormers attention is only available with CUDA and `xformers` installed"	,    )
   def 			__magic_name__			(			self				):
          self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2E-3				)

   def 			__magic_name__			(			self				):
          self._test_inference_batch_single_identical(expected_max_diff=2E-3				)


class 		a__						(      a_,			a_,			unittest.TestCase						):
   __lowerCAmelCase            =				StableDiffusionControlNetImgaImgPipeline
   __lowerCAmelCase            =				TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"""height""", """width"""}
   __lowerCAmelCase            =				TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
   __lowerCAmelCase            =				frozenset([]						)  # TO_DO: add image_params once refactored VaeImageProcessor.preprocess
   def 			__magic_name__			(			self				):
          torch.manual_seed(0				)
          lowercase    :				Optional[int]       		=							UNetaDConditionModel(
              block_out_channels=(32, 64)	,    layers_per_block=2	,    sample_size=32	,    in_channels=4	,    out_channels=4	,    down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")	,    up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")	,    cross_attention_dim=32	,    )
          torch.manual_seed(0				)

          def init_weights(_a				):
                 if isinstance(_a	,    torch.nn.Convad				):
                        torch.nn.init.normal(m.weight				)
                        m.bias.data.fill_(1.0				)

          lowercase    :				int       		=							ControlNetModel(
              block_out_channels=(32, 64)	,    layers_per_block=2	,    in_channels=4	,    down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")	,    cross_attention_dim=32	,    conditioning_embedding_out_channels=(16, 32)	,    )
          controlneta.controlnet_down_blocks.apply(_a				)

          torch.manual_seed(0				)
          lowercase    :				Optional[Any]       		=							ControlNetModel(
              block_out_channels=(32, 64)	,    layers_per_block=2	,    in_channels=4	,    down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")	,    cross_attention_dim=32	,    conditioning_embedding_out_channels=(16, 32)	,    )
          controlneta.controlnet_down_blocks.apply(_a				)

          torch.manual_seed(0				)
          lowercase    :				Optional[int]       		=							DDIMScheduler(
              beta_start=0.0_0_0_8_5	,    beta_end=0.0_1_2	,    beta_schedule="scaled_linear"	,    clip_sample=_a	,    set_alpha_to_one=_a	,    )
          torch.manual_seed(0				)
          lowercase    :				int       		=							AutoencoderKL(
              block_out_channels=[32, 64]	,    in_channels=3	,    out_channels=3	,    down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]	,    up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]	,    latent_channels=4	,    )
          torch.manual_seed(0				)
          lowercase    :				str       		=							CLIPTextConfig(
              bos_token_id=0	,    eos_token_id=2	,    hidden_size=32	,    intermediate_size=37	,    layer_norm_eps=1E-05	,    num_attention_heads=4	,    num_hidden_layers=5	,    pad_token_id=1	,    vocab_size=1_000	,    )
          lowercase    :				List[str]       		=							CLIPTextModel(_a				)
          lowercase    :				List[Any]       		=							CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"				)

          lowercase    :				List[str]       		=							MultiControlNetModel([controlneta, controlneta]				)

          lowercase    :				Any       		=							{
              "unet": unet,
              "controlnet": controlnet,
              "scheduler": scheduler,
              "vae": vae,
              "text_encoder": text_encoder,
              "tokenizer": tokenizer,
              "safety_checker": None,
              "feature_extractor": None,
          }
          return components
   def 			__magic_name__			(			self	,    _a	,    _a=0				):
          if str(_a				).startswith("mps"				):
                 lowercase    :				str       		=							torch.manual_seed(_a				)
          else:
                 lowercase    :				Dict       		=							torch.Generator(device=_a				).manual_seed(_a				)

          lowercase    :				Any       		=							2

          lowercase    :				Any       		=							[
              randn_tensor(
                  (1, 3, 32 * controlnet_embedder_scale_factor, 32 * controlnet_embedder_scale_factor)	,    generator=_a	,    device=torch.device(_a				)	,    ),
              randn_tensor(
                  (1, 3, 32 * controlnet_embedder_scale_factor, 32 * controlnet_embedder_scale_factor)	,    generator=_a	,    device=torch.device(_a				)	,    ),
          ]

          lowercase    :				Dict       		=							floats_tensor(control_image[0].shape	,    rng=random.Random(_a				)				).to(_a				)
          lowercase    :				Optional[int]       		=							image.cpu().permute(0	,    2	,    3	,    1				)[0]
          lowercase    :				Tuple       		=							Image.fromarray(np.uinta(_a				)				).convert("RGB"				).resize((64, 64)				)
          lowercase    :				Tuple       		=							{
              "prompt": "A painting of a squirrel eating a burger",
              "generator": generator,
              "num_inference_steps": 2,
              "guidance_scale": 6.0,
              "output_type": "numpy",
              "image": image,
              "control_image": control_image,
          }

          return inputs
   def 			__magic_name__			(			self				):
          lowercase    :				int       		=							self.get_dummy_components()
          lowercase    :				Tuple       		=							self.pipeline_class(**_a				)
          pipe.to(_a				)

          lowercase    :				Any       		=							1_0.0
          lowercase    :				List[str]       		=							4

          lowercase    :				List[str]       		=							self.get_dummy_inputs(_a				)
          lowercase    :				Dict       		=							steps
          lowercase    :				Dict       		=							scale
          lowercase    :				Union[str, Any]       		=							pipe(**_a				)[0]

          lowercase    :				Any       		=							self.get_dummy_inputs(_a				)
          lowercase    :				Optional[Any]       		=							steps
          lowercase    :				Optional[int]       		=							scale
          lowercase    :				Tuple       		=							pipe(**_a	,    control_guidance_start=0.1	,    control_guidance_end=0.2				)[0]

          lowercase    :				int       		=							self.get_dummy_inputs(_a				)
          lowercase    :				str       		=							steps
          lowercase    :				str       		=							scale
          lowercase    :				List[str]       		=							pipe(**_a	,    control_guidance_start=[0.1, 0.3]	,    control_guidance_end=[0.2, 0.7]				)[0]

          lowercase    :				Dict       		=							self.get_dummy_inputs(_a				)
          lowercase    :				Optional[int]       		=							steps
          lowercase    :				List[str]       		=							scale
          lowercase    :				Any       		=							pipe(**_a	,    control_guidance_start=0.4	,    control_guidance_end=[0.5, 0.8]				)[0]

          # make sure that all outputs are different
          assert np.sum(np.abs(output_a - output_a				)				) > 1E-3
          assert np.sum(np.abs(output_a - output_a				)				) > 1E-3
          assert np.sum(np.abs(output_a - output_a				)				) > 1E-3
   def 			__magic_name__			(			self				):
          return self._test_attention_slicing_forward_pass(expected_max_diff=2E-3				)
   @unittest.skipIf(
       torch_device != "cuda" or not is_xformers_available()	,    reason="XFormers attention is only available with CUDA and `xformers` installed"	,    )
   def 			__magic_name__			(			self				):
          self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2E-3				)
   def 			__magic_name__			(			self				):
          self._test_inference_batch_single_identical(expected_max_diff=2E-3				)

   def 			__magic_name__			(			self				):
          lowercase    :				List[Any]       		=							self.get_dummy_components()
          lowercase    :				int       		=							self.pipeline_class(**_a				)
          pipe.to(_a				)
          pipe.set_progress_bar_config(disable=_a				)
          with tempfile.TemporaryDirectory() as tmpdir:
                 try:
                        # save_pretrained is not implemented for Multi-ControlNet
                        pipe.save_pretrained(_a				)
                 except NotImplementedError:
                        pass


@slow
@require_torch_gpu
class 		a__						(      unittest.TestCase						):
   def 			__magic_name__			(			self				):
          super().tearDown()
          gc.collect()
          torch.cuda.empty_cache()

   def 			__magic_name__			(			self				):
          lowercase    :				List[Any]       		=							ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny"				)

          lowercase    :				Tuple       		=							StableDiffusionControlNetImgaImgPipeline.from_pretrained(
              "runwayml/stable-diffusion-v1-5"	,    safety_checker=_a	,    controlnet=_a				)
          pipe.enable_model_cpu_offload()
          pipe.set_progress_bar_config(disable=_a				)

          lowercase    :				Optional[Any]       		=							torch.Generator(device="cpu"				).manual_seed(0				)
          lowercase    :				int       		=							"evil space-punk bird"
          lowercase    :				Optional[Any]       		=							load_image(
              "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png"				).resize((512, 512)				)
          lowercase    :				List[str]       		=							load_image(
              "https://huggingface.co/lllyasviel/sd-controlnet-canny/resolve/main/images/bird.png"				).resize((512, 512)				)

          lowercase    :				List[Any]       		=							pipe(
              _a	,    _a	,    control_image=_a	,    generator=_a	,    output_type="np"	,    num_inference_steps=50	,    strength=0.6	,    )

          lowercase    :				Any       		=							output.images[0]

          assert image.shape == (512, 512, 3)

          lowercase    :				int       		=							load_numpy(
              "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/img2img.npy"				)

          assert np.abs(expected_image - image				).max() < 9E-2




"""simple docstring"""




import unittest

from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


_A			:       int   		=       get_tests_dir("""fixtures/spiece.model""")

@require_sentencepiece
@require_tokenizers
class 		a__						(      a_,			unittest.TestCase						):
   __lowerCAmelCase            =				DebertaVaTokenizer
   __lowerCAmelCase            =				DebertaVaTokenizerFast
   __lowerCAmelCase            =				True
   __lowerCAmelCase            =				True
   def 			__magic_name__			(			self				):
          super().setUp()

          # We have a SentencePiece fixture for testing
          lowercase    :				Any       		=							DebertaVaTokenizer(_a	,    unk_token="<unk>"				)
          tokenizer.save_pretrained(self.tmpdirname				)
   def 			__magic_name__			(			self	,    _a				):
          lowercase    :				int       		=							"this is a test"
          lowercase    :				Tuple       		=							"this is a test"
          return input_text, output_text
   def 			__magic_name__			(			self				):
          lowercase    :				List[Any]       		=							"<pad>"
          lowercase    :				List[str]       		=							0

          self.assertEqual(self.get_tokenizer()._convert_token_to_id(_a				)	,    _a				)
          self.assertEqual(self.get_tokenizer()._convert_id_to_token(_a				)	,    _a				)
   def 			__magic_name__			(			self				):
          lowercase    :				int       		=							list(self.get_tokenizer().get_vocab().keys()				)
          self.assertEqual(vocab_keys[0]	,    "<pad>"				)
          self.assertEqual(vocab_keys[1]	,    "<unk>"				)
          self.assertEqual(vocab_keys[-1]	,    "[PAD]"				)
          self.assertEqual(len(_a				)	,    30_001				)
   def 			__magic_name__			(			self				):
          self.assertEqual(self.get_tokenizer().vocab_size	,    30_000				)
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				List[str]       		=							" \tHeLLo!how  \n Are yoU?  "
          lowercase    :				str       		=							["▁hello", "!", "how", "▁are", "▁you", "?"]
          # fmt: on

          lowercase    :				Union[str, Any]       		=							DebertaVaTokenizer(_a	,    do_lower_case=_a				)
          lowercase    :				Any       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)

          lowercase    :				str       		=							DebertaVaTokenizerFast(_a	,    do_lower_case=_a				)
          lowercase    :				Optional[Any]       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)
   @unittest.skip("There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."				)
   def 			__magic_name__			(			self				):
          pass
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				Optional[Any]       		=							"I was born in 92000, and this is falsé."
          lowercase    :				Tuple       		=							["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
          # fmt: on

          lowercase    :				List[Any]       		=							DebertaVaTokenizer(_a	,    split_by_punct=_a				)
          lowercase    :				Tuple       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)

          lowercase    :				Union[str, Any]       		=							DebertaVaTokenizerFast(_a	,    split_by_punct=_a				)
          lowercase    :				Any       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				int       		=							"I was born in 92000, and this is falsé."
          lowercase    :				Tuple       		=							["▁i", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
          # fmt: on

          lowercase    :				List[str]       		=							DebertaVaTokenizer(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				Optional[Any]       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)
          self.assertListEqual(_a	,    _a				)

          lowercase    :				Union[str, Any]       		=							DebertaVaTokenizerFast(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				Optional[int]       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)
          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				List[Any]       		=							"I was born in 92000, and this is falsé."
          lowercase    :				Optional[int]       		=							["▁i", "▁was", "▁born", "▁in", "▁9", "2000", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", ".", ]
          # fmt: on

          lowercase    :				List[Any]       		=							DebertaVaTokenizer(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				Optional[int]       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)

          lowercase    :				Optional[int]       		=							DebertaVaTokenizerFast(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				Dict       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				int       		=							"I was born in 92000, and this is falsé."
          lowercase    :				Dict       		=							["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
          # fmt: on

          lowercase    :				Union[str, Any]       		=							DebertaVaTokenizer(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				Any       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)

          lowercase    :				Union[str, Any]       		=							DebertaVaTokenizerFast(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				Dict       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				Dict       		=							" \tHeLLo!how  \n Are yoU?  "
          lowercase    :				str       		=							["▁", "<unk>", "e", "<unk>", "o", "!", "how", "▁", "<unk>", "re", "▁yo", "<unk>", "?"]
          # fmt: on

          lowercase    :				Optional[int]       		=							DebertaVaTokenizer(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				int       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)

          lowercase    :				List[str]       		=							DebertaVaTokenizerFast(_a	,    do_lower_case=_a	,    split_by_punct=_a				)
          lowercase    :				List[Any]       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)

          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          lowercase    :				str       		=							self.get_tokenizer()
          lowercase    :				Dict       		=							self.get_rust_tokenizer()

          lowercase    :				str       		=							"I was born in 92000, and this is falsé."

          lowercase    :				Optional[Any]       		=							tokenizer.convert_ids_to_tokens(tokenizer.encode(_a	,    add_special_tokens=_a				)				)
          lowercase    :				Dict       		=							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_a	,    add_special_tokens=_a				)				)
          self.assertListEqual(_a	,    _a				)

          lowercase    :				str       		=							tokenizer.encode(_a	,    add_special_tokens=_a				)
          lowercase    :				Dict       		=							rust_tokenizer.encode(_a	,    add_special_tokens=_a				)
          self.assertListEqual(_a	,    _a				)

          lowercase    :				Optional[int]       		=							self.get_rust_tokenizer()
          lowercase    :				Tuple       		=							tokenizer.encode(_a				)
          lowercase    :				List[str]       		=							rust_tokenizer.encode(_a				)
          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          lowercase    :				str       		=							"This is a test"
          lowercase    :				Tuple       		=							[13, 1, 4_398, 25, 21, 1_289]
          lowercase    :				Optional[int]       		=							["▁", "T", "his", "▁is", "▁a", "▁test"]
          lowercase    :				Optional[Any]       		=							["▁", "<unk>", "his", "▁is", "▁a", "▁test"]

          lowercase    :				Any       		=							DebertaVaTokenizer(_a	,    keep_accents=_a				)
          lowercase    :				Dict       		=							DebertaVaTokenizerFast(_a	,    keep_accents=_a				)

          lowercase    :				str       		=							tokenizer.encode(_a	,    add_special_tokens=_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				str       		=							tokenizer.tokenize(_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				str       		=							tokenizer.convert_ids_to_tokens(_a				)
          self.assertListEqual(_a	,    _a				)

          lowercase    :				int       		=							rust_tokenizer.encode(_a	,    add_special_tokens=_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				Any       		=							rust_tokenizer.tokenize(_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				Union[str, Any]       		=							rust_tokenizer.convert_ids_to_tokens(_a				)
          self.assertListEqual(_a	,    _a				)

          # fmt: off
          lowercase    :				int       		=							"I was born in 92000, and this is falsé."
          lowercase    :				Any       		=							[13, 1, 23, 386, 19, 561, 3_050, 15, 17, 48, 25, 8_256, 18, 1, 9]
          lowercase    :				List[str]       		=							["▁", "I", "▁was", "▁born", "▁in", "▁9", "2000", ",", "▁and", "▁this", "▁is", "▁fal", "s", "é", ".", ]
          lowercase    :				str       		=							["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", ".", ]
          # fmt: on

          lowercase    :				Tuple       		=							tokenizer.encode(_a	,    add_special_tokens=_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				List[Any]       		=							tokenizer.tokenize(_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				str       		=							tokenizer.convert_ids_to_tokens(_a				)
          self.assertListEqual(_a	,    _a				)

          lowercase    :				Optional[int]       		=							rust_tokenizer.encode(_a	,    add_special_tokens=_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				List[Any]       		=							rust_tokenizer.tokenize(_a				)
          self.assertListEqual(_a	,    _a				)
          lowercase    :				List[Any]       		=							rust_tokenizer.convert_ids_to_tokens(_a				)
          self.assertListEqual(_a	,    _a				)
   def 			__magic_name__			(			self				):
          lowercase    :				Optional[int]       		=							DebertaVaTokenizer(_a				)

          lowercase    :				List[Any]       		=							tokenizer.encode("sequence builders"				)
          lowercase    :				Dict       		=							tokenizer.encode("multi-sequence build"				)

          lowercase    :				List[Any]       		=							tokenizer.build_inputs_with_special_tokens(_a				)
          lowercase    :				Dict       		=							tokenizer.build_inputs_with_special_tokens(_a	,    _a				)

          self.assertEqual([tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]	,    _a				)
          self.assertEqual(
              [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [tokenizer.sep_token_id]	,    _a	,    )

   @slow
   def 			__magic_name__			(			self				):
          # fmt: off
          lowercase    :				Dict       		=							{"input_ids": [[1, 39_867, 36, 19_390, 486, 27, 35_052, 81_436, 18, 60_685, 1_225, 7, 35_052, 81_436, 18, 9_367, 16_899, 18, 15_937, 53, 594, 773, 18, 16_287, 30_465, 36, 15_937, 6, 41_139, 38, 36_979, 60_763, 191, 6, 34_132, 99, 6, 50_538, 390, 43_230, 6, 34_132, 2_779, 20_850, 14, 699, 1_072, 1_194, 36, 382, 10_901, 53, 7, 699, 1_072, 2_084, 36, 20_422, 630, 53, 19, 105, 3_049, 1_896, 1_053, 16_899, 1_506, 11, 37_978, 4_243, 7, 1_237, 31_869, 200, 16_566, 654, 6, 35_052, 81_436, 7, 55_630, 13_593, 4, 2], [1, 26, 15_011, 13, 667, 8, 1_053, 18, 23_611, 1_237, 72_356, 12_820, 34, 104_134, 1_209, 35, 13_313, 6_627, 21, 202, 347, 7, 164, 2_399, 11, 46, 4_485, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 5, 1_232, 2_864, 15_785, 14_951, 105, 5, 8_581, 1_250, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "token_type_ids": [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "attention_mask": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
          # fmt: on

          self.tokenizer_integration_test_util(
              expected_encoding=_a	,    model_name="microsoft/deberta-v2-xlarge"	,    revision="ad6e42c1532ddf3a15c39246b63f5559d558b670"	,    )


