




"""simple docstring"""







from typing import Optional, Tuple, Union

import flax
import flax.linen as nn
import jax
import jax.numpy as jnp
from flax.core.frozen_dict import FrozenDict

from ..configuration_utils import ConfigMixin, flax_register_to_config
from ..utils import BaseOutput
from .embeddings_flax import FlaxTimestepEmbedding, FlaxTimesteps
from .modeling_flax_utils import FlaxModelMixin
from .unet_ad_blocks_flax import (
    FlaxCrossAttnDownBlockaD,
    FlaxCrossAttnUpBlockaD,
    FlaxDownBlockaD,
    FlaxUNetMidBlockaDCrossAttn,
    FlaxUpBlockaD,
)







@flax.struct.dataclass
class  UpperCamelCase	(    _UpperCAmelCase						):
   lowercase							=						42







@flax_register_to_config
class  UpperCamelCase	(    nn.Module		,   _UpperCAmelCase		,   _UpperCAmelCase						):
   lowercase							=						3_2
   lowercase							=						4
   lowercase							=						4
   lowercase							=						(
       "CrossAttnDownBlock2D",
       "CrossAttnDownBlock2D",
       "CrossAttnDownBlock2D",
       "DownBlock2D",
   )
   lowercase							=						("UpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D")
   lowercase							=						False
   lowercase							=						(3_2_0, 6_4_0, 1_2_8_0, 1_2_8_0)
   lowercase							=						2
   lowercase							=						8
   lowercase							=						None
   lowercase							=						1_2_8_0
   lowercase							=						0.0
   lowercase							=						False
   lowercase							=						jnp.floataa
   lowercase							=						True
   lowercase							=						0
   lowercase							=						False
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase    )			->   FrozenDict:


        '''simple docstring'''


        lowercase_			:       Any									=			(1, self.in_channels, self.sample_size, self.sample_size)
        lowercase_			:       List[str]									=			jnp.zeros(__UpperCamelCase  ,dtype=jnp.floataa    )
        lowercase_			:       Optional[Any]									=			jnp.ones((1,)  ,dtype=jnp.intaa    )
        lowercase_			:       int									=			jnp.zeros((1, 1, self.cross_attention_dim)  ,dtype=jnp.floataa    )

        lowercase_							,						lowercase_			:       Union[str, Any]									=			jax.random.split(__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			{'params': params_rng, 'dropout': dropout_rng}

        return self.init(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )["params"]
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        lowercase_			:       Optional[int]									=			self.block_out_channels
        lowercase_			:       int									=			block_out_channels[0] * 4

        if self.num_attention_heads is not None:
             raise ValueError(
                 'At the moment it is not possible to define the number of attention heads via `num_attention_heads` because of a naming issue as described in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131. Passing `num_attention_heads` will only be supported in diffusers v0.19.'    )

        # If `num_attention_heads` is not defined (which is the case for most models)
        # it will default to `attention_head_dim`. This looks weird upon first reading it and it is.
        # The reason for this behavior is to correct for incorrectly named variables that were introduced
        # when this library was created. The incorrect naming was only discovered much later in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131
        # Changing `attention_head_dim` to `num_attention_heads` for 40,000+ configurations is too backwards breaking
        # which is why we correct for the naming here.
        lowercase_			:       Any									=			self.num_attention_heads or self.attention_head_dim

        # input
        lowercase_			:       Optional[int]									=			nn.Conv(
            block_out_channels[0]  ,kernel_size=(3, 3)  ,strides=(1, 1)  ,padding=((1, 1), (1, 1))  ,dtype=self.dtype  ,)

        # time
        lowercase_			:       List[str]									=			FlaxTimesteps(
            block_out_channels[0]  ,flip_sin_to_cos=self.flip_sin_to_cos  ,freq_shift=self.config.freq_shift    )
        lowercase_			:       Tuple									=			FlaxTimestepEmbedding(__UpperCamelCase  ,dtype=self.dtype    )

        lowercase_			:       List[str]									=			self.only_cross_attention
        if isinstance(__UpperCamelCase  ,__UpperCamelCase    ):
             lowercase_			:       Optional[Any]									=			(only_cross_attention,) * len(self.down_block_types    )

        if isinstance(__UpperCamelCase  ,__UpperCamelCase    ):
             lowercase_			:       List[Any]									=			(num_attention_heads,) * len(self.down_block_types    )

        # down
        lowercase_			:       Optional[int]									=			[]
        lowercase_			:       Optional[int]									=			block_out_channels[0]
        for i, down_block_type in enumerate(self.down_block_types    ):
             lowercase_			:       Dict									=			output_channel
             lowercase_			:       List[str]									=			block_out_channels[i]
             lowercase_			:       Union[str, Any]									=			i == len(__UpperCamelCase    ) - 1

             if down_block_type == "CrossAttnDownBlock2D":
                  lowercase_			:       List[Any]									=			FlaxCrossAttnDownBlockaD(
                      in_channels=__UpperCamelCase  ,out_channels=__UpperCamelCase  ,dropout=self.dropout  ,num_layers=self.layers_per_block  ,num_attention_heads=num_attention_heads[i]  ,add_downsample=not is_final_block  ,use_linear_projection=self.use_linear_projection  ,only_cross_attention=only_cross_attention[i]  ,use_memory_efficient_attention=self.use_memory_efficient_attention  ,dtype=self.dtype  ,)
             else:
                  lowercase_			:       Any									=			FlaxDownBlockaD(
                      in_channels=__UpperCamelCase  ,out_channels=__UpperCamelCase  ,dropout=self.dropout  ,num_layers=self.layers_per_block  ,add_downsample=not is_final_block  ,dtype=self.dtype  ,)

             down_blocks.append(__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			down_blocks

        # mid
        lowercase_			:       List[Any]									=			FlaxUNetMidBlockaDCrossAttn(
            in_channels=block_out_channels[-1]  ,dropout=self.dropout  ,num_attention_heads=num_attention_heads[-1]  ,use_linear_projection=self.use_linear_projection  ,use_memory_efficient_attention=self.use_memory_efficient_attention  ,dtype=self.dtype  ,)

        # up
        lowercase_			:       Tuple									=			[]
        lowercase_			:       Dict									=			list(reversed(__UpperCamelCase    )    )
        lowercase_			:       List[str]									=			list(reversed(__UpperCamelCase    )    )
        lowercase_			:       Optional[Any]									=			list(reversed(__UpperCamelCase    )    )
        lowercase_			:       Tuple									=			reversed_block_out_channels[0]
        for i, up_block_type in enumerate(self.up_block_types    ):
             lowercase_			:       Dict									=			output_channel
             lowercase_			:       str									=			reversed_block_out_channels[i]
             lowercase_			:       List[str]									=			reversed_block_out_channels[min(i + 1  ,len(__UpperCamelCase    ) - 1    )]

             lowercase_			:       List[str]									=			i == len(__UpperCamelCase    ) - 1

             if up_block_type == "CrossAttnUpBlock2D":
                  lowercase_			:       Any									=			FlaxCrossAttnUpBlockaD(
                      in_channels=__UpperCamelCase  ,out_channels=__UpperCamelCase  ,prev_output_channel=__UpperCamelCase  ,num_layers=self.layers_per_block + 1  ,num_attention_heads=reversed_num_attention_heads[i]  ,add_upsample=not is_final_block  ,dropout=self.dropout  ,use_linear_projection=self.use_linear_projection  ,only_cross_attention=only_cross_attention[i]  ,use_memory_efficient_attention=self.use_memory_efficient_attention  ,dtype=self.dtype  ,)
             else:
                  lowercase_			:       Optional[int]									=			FlaxUpBlockaD(
                      in_channels=__UpperCamelCase  ,out_channels=__UpperCamelCase  ,prev_output_channel=__UpperCamelCase  ,num_layers=self.layers_per_block + 1  ,add_upsample=not is_final_block  ,dropout=self.dropout  ,dtype=self.dtype  ,)

             up_blocks.append(__UpperCamelCase    )
             lowercase_			:       Any									=			output_channel
        lowercase_			:       List[Any]									=			up_blocks

        # out
        lowercase_			:       Dict									=			nn.GroupNorm(num_groups=32  ,epsilon=1e-5    )
        lowercase_			:       List[Any]									=			nn.Conv(
            self.out_channels  ,kernel_size=(3, 3)  ,strides=(1, 1)  ,padding=((1, 1), (1, 1))  ,dtype=self.dtype  ,)







   def __call__(    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase=None  ,__UpperCamelCase=None  ,__UpperCamelCase = True  ,__UpperCamelCase = False  ,)			->   Union[FlaxUNetaDConditionOutput, Tuple]:


        '''simple docstring'''


        if not isinstance(__UpperCamelCase  ,jnp.ndarray    ):
             lowercase_			:       Optional[int]									=			jnp.array([timesteps]  ,dtype=jnp.intaa    )
        elif isinstance(__UpperCamelCase  ,jnp.ndarray    ) and len(timesteps.shape    ) == 0:
             lowercase_			:       List[Any]									=			timesteps.astype(dtype=jnp.floataa    )
             lowercase_			:       Union[str, Any]									=			jnp.expand_dims(__UpperCamelCase  ,0    )

        lowercase_			:       Tuple									=			self.time_proj(__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			self.time_embedding(__UpperCamelCase    )

        # 2. pre-process
        lowercase_			:       str									=			jnp.transpose(__UpperCamelCase  ,(0, 2, 3, 1)    )
        lowercase_			:       Union[str, Any]									=			self.conv_in(__UpperCamelCase    )

        # 3. down
        lowercase_			:       Optional[Any]									=			(sample,)
        for down_block in self.down_blocks:
             if isinstance(__UpperCamelCase  ,__UpperCamelCase    ):
                  lowercase_							,						lowercase_			:       Optional[Any]									=			down_block(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,deterministic=not train    )
             else:
                  lowercase_							,						lowercase_			:       Any									=			down_block(__UpperCamelCase  ,__UpperCamelCase  ,deterministic=not train    )
             down_block_res_samples += res_samples

        if down_block_additional_residuals is not None:
             lowercase_			:       Optional[int]									=			()

             for down_block_res_sample, down_block_additional_residual in zip(
                 __UpperCamelCase  ,__UpperCamelCase    ):
                  down_block_res_sample += down_block_additional_residual
                  new_down_block_res_samples += (down_block_res_sample,)

             lowercase_			:       List[str]									=			new_down_block_res_samples

        # 4. mid
        lowercase_			:       int									=			self.mid_block(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,deterministic=not train    )

        if mid_block_additional_residual is not None:
             sample += mid_block_additional_residual

        # 5. up
        for up_block in self.up_blocks:
             lowercase_			:       List[Any]									=			down_block_res_samples[-(self.layers_per_block + 1) :]
             lowercase_			:       List[str]									=			down_block_res_samples[: -(self.layers_per_block + 1)]
             if isinstance(__UpperCamelCase  ,__UpperCamelCase    ):
                  lowercase_			:       List[Any]									=			up_block(
                      __UpperCamelCase  ,temb=__UpperCamelCase  ,encoder_hidden_states=__UpperCamelCase  ,res_hidden_states_tuple=__UpperCamelCase  ,deterministic=not train  ,)
             else:
                  lowercase_			:       Union[str, Any]									=			up_block(__UpperCamelCase  ,temb=__UpperCamelCase  ,res_hidden_states_tuple=__UpperCamelCase  ,deterministic=not train    )

        # 6. post-process
        lowercase_			:       int									=			self.conv_norm_out(__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			nn.silu(__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			self.conv_out(__UpperCamelCase    )
        lowercase_			:       Any									=			jnp.transpose(__UpperCamelCase  ,(0, 3, 1, 2)    )

        if not return_dict:
             return (sample,)

        return FlaxUNetaDConditionOutput(sample=__UpperCamelCase    )


"""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


__SCREAMING_SNAKE_CASE								=get_tests_dir("fixtures/spiece.model")







@require_sentencepiece
@require_tokenizers
class  UpperCamelCase	(    lowercase_		,   unittest.TestCase						):
   lowercase							=						DebertaVaTokenizer
   lowercase							=						DebertaVaTokenizerFast
   lowercase							=						True
   lowercase							=						True
   def     _UpperCAmelCase     (    self    )			->   List[str]:


        '''simple docstring'''


        super().setUp()

        # We have a SentencePiece fixture for testing
        lowercase_			:       Any									=			DebertaVaTokenizer(__UpperCamelCase  ,unk_token='<unk>'    )
        tokenizer.save_pretrained(self.tmpdirname    )
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase    )			->   Any:


        '''simple docstring'''


        lowercase_			:       Union[str, Any]									=			'this is a test'
        lowercase_			:       str									=			'this is a test'
        return input_text, output_text
   def     _UpperCAmelCase     (    self    )			->   Optional[Any]:


        '''simple docstring'''


        lowercase_			:       Optional[int]									=			'<pad>'
        lowercase_			:       str									=			0

        self.assertEqual(self.get_tokenizer()._convert_token_to_id(__UpperCamelCase    )  ,__UpperCamelCase    )
        self.assertEqual(self.get_tokenizer()._convert_id_to_token(__UpperCamelCase    )  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        lowercase_			:       Union[str, Any]									=			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(__UpperCamelCase    )  ,3_0001    )
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        self.assertEqual(self.get_tokenizer().vocab_size  ,3_0000    )
   def     _UpperCAmelCase     (    self    )			->   List[str]:


        '''simple docstring'''


        lowercase_			:       Optional[Any]									=			' \tHeLLo!how  \n Are yoU?  '
        lowercase_			:       Optional[int]									=			['▁hello', '!', 'how', '▁are', '▁you', '?']
        # fmt: on

        lowercase_			:       int									=			DebertaVaTokenizer(__UpperCamelCase  ,do_lower_case=__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Optional[Any]									=			DebertaVaTokenizerFast(__UpperCamelCase  ,do_lower_case=__UpperCamelCase    )
        lowercase_			:       Dict									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   @unittest.skip('There is an inconsistency between slow and fast tokenizer due to a bug in the fast one.'    )
   def     _UpperCAmelCase     (    self    )			->   Union[str, Any]:


        '''simple docstring'''


        pass
   @unittest.skip('There is an inconsistency between slow and fast tokenizer due to a bug in the fast one.'    )
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        pass
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       Any									=			'I was born in 92000, and this is falsé.'
        lowercase_			:       Union[str, Any]									=			['▁', '<unk>', '▁was', '▁born', '▁in', '▁9', '2000', '▁', ',', '▁and', '▁this', '▁is', '▁fal', 's', '<unk>', '▁', '.', ]
        # fmt: on

        lowercase_			:       List[str]									=			DebertaVaTokenizer(__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Any									=			DebertaVaTokenizerFast(__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       Tuple									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        lowercase_			:       Any									=			'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(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       Dict									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Tuple									=			DebertaVaTokenizerFast(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       Dict									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Dict:


        '''simple docstring'''


        lowercase_			:       str									=			'I was born in 92000, and this is falsé.'
        lowercase_			:       Optional[Any]									=			['▁i', '▁was', '▁born', '▁in', '▁9', '2000', ',', '▁and', '▁this', '▁is', '▁fal', 's', '<unk>', '.', ]
        # fmt: on

        lowercase_			:       Union[str, Any]									=			DebertaVaTokenizer(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       Dict									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Tuple									=			DebertaVaTokenizerFast(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       Tuple									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Dict:


        '''simple docstring'''


        lowercase_			:       Tuple									=			'I was born in 92000, and this is falsé.'
        lowercase_			:       Optional[int]									=			['▁', '<unk>', '▁was', '▁born', '▁in', '▁9', '2000', '▁', ',', '▁and', '▁this', '▁is', '▁fal', 's', '<unk>', '▁', '.', ]
        # fmt: on

        lowercase_			:       Optional[int]									=			DebertaVaTokenizer(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       str									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Union[str, Any]									=			DebertaVaTokenizerFast(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       List[Any]									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Optional[Any]:


        '''simple docstring'''


        lowercase_			:       Tuple									=			' \tHeLLo!how  \n Are yoU?  '
        lowercase_			:       List[str]									=			['▁', '<unk>', 'e', '<unk>', 'o', '!', 'how', '▁', '<unk>', 're', '▁yo', '<unk>', '?']
        # fmt: on

        lowercase_			:       str									=			DebertaVaTokenizer(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       int									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Union[str, Any]									=			DebertaVaTokenizerFast(__UpperCamelCase  ,do_lower_case=__UpperCamelCase  ,split_by_punct=__UpperCamelCase    )
        lowercase_			:       List[Any]									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )

        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       Optional[int]									=			self.get_tokenizer()
        lowercase_			:       int									=			self.get_rust_tokenizer()

        lowercase_			:       Dict									=			'I was born in 92000, and this is falsé.'

        lowercase_			:       Any									=			tokenizer.convert_ids_to_tokens(tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )
        lowercase_			:       Union[str, Any]									=			rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Optional[int]									=			tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )
        lowercase_			:       str									=			rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Optional[int]									=			self.get_rust_tokenizer()
        lowercase_			:       Optional[Any]									=			tokenizer.encode(__UpperCamelCase    )
        lowercase_			:       Dict									=			rust_tokenizer.encode(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Dict:


        '''simple docstring'''


        lowercase_			:       Optional[int]									=			'This is a test'
        lowercase_			:       Any									=			[13, 1, 4398, 25, 21, 1289]
        lowercase_			:       Union[str, Any]									=			['▁', 'T', 'his', '▁is', '▁a', '▁test']
        lowercase_			:       str									=			['▁', '<unk>', 'his', '▁is', '▁a', '▁test']

        lowercase_			:       Optional[int]									=			DebertaVaTokenizer(__UpperCamelCase  ,keep_accents=__UpperCamelCase    )
        lowercase_			:       str									=			DebertaVaTokenizerFast(__UpperCamelCase  ,keep_accents=__UpperCamelCase    )

        lowercase_			:       Optional[int]									=			tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       List[Any]									=			tokenizer.tokenize(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       Any									=			tokenizer.convert_ids_to_tokens(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       str									=			rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			rust_tokenizer.tokenize(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       str									=			rust_tokenizer.convert_ids_to_tokens(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

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

        lowercase_			:       List[str]									=			tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       List[str]									=			tokenizer.tokenize(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       List[Any]									=			tokenizer.convert_ids_to_tokens(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )

        lowercase_			:       Tuple									=			rust_tokenizer.encode(__UpperCamelCase  ,add_special_tokens=__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			rust_tokenizer.tokenize(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
        lowercase_			:       Dict									=			rust_tokenizer.convert_ids_to_tokens(__UpperCamelCase    )
        self.assertListEqual(__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Dict:


        '''simple docstring'''


        lowercase_			:       Dict									=			DebertaVaTokenizer(__UpperCamelCase    )

        lowercase_			:       int									=			tokenizer.encode('sequence builders'    )
        lowercase_			:       Tuple									=			tokenizer.encode('multi-sequence build'    )

        lowercase_			:       Dict									=			tokenizer.build_inputs_with_special_tokens(__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			tokenizer.build_inputs_with_special_tokens(__UpperCamelCase  ,__UpperCamelCase    )

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







   @slow
   def     _UpperCAmelCase     (    self    )			->   List[str]:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			{'input_ids': [[1, 3_9867, 36, 1_9390, 486, 27, 3_5052, 8_1436, 18, 6_0685, 1225, 7, 3_5052, 8_1436, 18, 9367, 1_6899, 18, 1_5937, 53, 594, 773, 18, 1_6287, 3_0465, 36, 1_5937, 6, 4_1139, 38, 3_6979, 6_0763, 191, 6, 3_4132, 99, 6, 5_0538, 390, 4_3230, 6, 3_4132, 2779, 2_0850, 14, 699, 1072, 1194, 36, 382, 1_0901, 53, 7, 699, 1072, 2084, 36, 2_0422, 630, 53, 19, 105, 3049, 1896, 1053, 1_6899, 1506, 11, 3_7978, 4243, 7, 1237, 3_1869, 200, 1_6566, 654, 6, 3_5052, 8_1436, 7, 5_5630, 1_3593, 4, 2], [1, 26, 1_5011, 13, 667, 8, 1053, 18, 2_3611, 1237, 7_2356, 1_2820, 34, 10_4134, 1209, 35, 1_3313, 6627, 21, 202, 347, 7, 164, 2399, 11, 46, 4485, 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, 1232, 2864, 1_5785, 1_4951, 105, 5, 8581, 1250, 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=__UpperCamelCase  ,model_name='microsoft/deberta-v2-xlarge'  ,revision='ad6e42c1532ddf3a15c39246b63f5559d558b670'  ,)

