






from typing import List, Optional, Tuple, Union

import torch
from torch import nn
from torch.nn import CrossEntropyLoss

from ... import AutoBackbone
from ...modeling_outputs import SemanticSegmenterOutput
from ...modeling_utils import PreTrainedModel
from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
from ...utils.backbone_utils import BackboneMixin
from .configuration_upernet import UperNetConfig


snake_case     					=		[
    """openmmlab/upernet-convnext-tiny""",
    # See all UperNet models at https://huggingface.co/models?filter=upernet
]

# General docstring
snake_case     					=		"""UperNetConfig"""


class 			SCREAMING_SNAKE_CASE      (      nn.Module       ):
     '''simple docstring'''


     def __init__(					self							:						Optional[Any]       ,			UpperCAmelCase_							:						int       ,			UpperCAmelCase_							:						int       ,			UpperCAmelCase_							:						Union[int, Tuple[int, int]]       ,			UpperCAmelCase_							:						Union[int, Tuple[int, int], str] = 0       ,			UpperCAmelCase_							:						bool = False       ,			UpperCAmelCase_							:						Union[int, Tuple[int, int]] = 1       ,			):
       super().__init__()
       SCREAMING_SNAKE_CASE							:   str						    =     nn.Convad(
           in_channels=UpperCAmelCase_       ,			out_channels=UpperCAmelCase_       ,			kernel_size=UpperCAmelCase_       ,			padding=UpperCAmelCase_       ,			bias=UpperCAmelCase_       ,			dilation=UpperCAmelCase_       ,			)
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     nn.BatchNormad(UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   Tuple						    =     nn.ReLU()






     def 					_A							(					self							:						Union[str, Any]       ,			UpperCAmelCase_							:						torch.Tensor   ):
       SCREAMING_SNAKE_CASE							:   Any						    =     self.conv(UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   Dict						    =     self.batch_norm(UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     self.activation(UpperCAmelCase_   )

       return output





class 			SCREAMING_SNAKE_CASE      (      nn.Module       ):
     '''simple docstring'''


     def __init__(					self							:						Union[str, Any]       ,			UpperCAmelCase_							:						int       ,			UpperCAmelCase_							:						int       ,			UpperCAmelCase_							:						int   ):
       super().__init__()
       SCREAMING_SNAKE_CASE							:   str						    =     [
           nn.AdaptiveAvgPoolad(UpperCAmelCase_   ),
           UperNetConvModule(UpperCAmelCase_       ,			UpperCAmelCase_       ,			kernel_size=1   ),
       ]
       for i, layer in enumerate(self.layers   ):
         self.add_module(str(UpperCAmelCase_   )       ,			UpperCAmelCase_   )






     def 					_A							(					self							:						Any       ,			UpperCAmelCase_							:						torch.Tensor   ):
       SCREAMING_SNAKE_CASE							:   Optional[int]						    =     input
       for layer in self.layers:
         SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     layer(UpperCAmelCase_   )
       return hidden_state





class 			SCREAMING_SNAKE_CASE      (      nn.Module       ):
     '''simple docstring'''


     def __init__(					self							:						Dict       ,			UpperCAmelCase_							:						Tuple[int, ...]       ,			UpperCAmelCase_							:						int       ,			UpperCAmelCase_							:						int       ,			UpperCAmelCase_							:						bool   ):
       super().__init__()
       SCREAMING_SNAKE_CASE							:   Dict						    =     pool_scales
       SCREAMING_SNAKE_CASE							:   Optional[int]						    =     align_corners
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     in_channels
       SCREAMING_SNAKE_CASE							:   List[str]						    =     channels
       SCREAMING_SNAKE_CASE							:   str						    =     []
       for i, pool_scale in enumerate(UpperCAmelCase_   ):
         SCREAMING_SNAKE_CASE							:   Optional[int]						    =     UperNetPyramidPoolingBlock(pool_scale=UpperCAmelCase_       ,			in_channels=UpperCAmelCase_       ,			channels=UpperCAmelCase_   )
         self.blocks.append(UpperCAmelCase_   )
         self.add_module(str(UpperCAmelCase_   )       ,			UpperCAmelCase_   )






     def 					_A							(					self							:						Tuple       ,			UpperCAmelCase_							:						torch.Tensor   ):
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     []
       for ppm in self.blocks:
         SCREAMING_SNAKE_CASE							:   Dict						    =     ppm(UpperCAmelCase_   )
         SCREAMING_SNAKE_CASE							:   Tuple						    =     nn.functional.interpolate(
             UpperCAmelCase_       ,			size=x.size()[2:]       ,			mode="bilinear"       ,			align_corners=self.align_corners   )
         ppm_outs.append(UpperCAmelCase_   )
       return ppm_outs





class 			SCREAMING_SNAKE_CASE      (      nn.Module       ):
     '''simple docstring'''


     def __init__(					self							:						str       ,			UpperCAmelCase_							:						Dict       ,			UpperCAmelCase_							:						Optional[Any]   ):
       super().__init__()

       SCREAMING_SNAKE_CASE							:   Tuple						    =     config
       SCREAMING_SNAKE_CASE							:   List[str]						    =     config.pool_scales  # e.g. (1, 2, 3, 6)
       SCREAMING_SNAKE_CASE							:   Dict						    =     in_channels
       SCREAMING_SNAKE_CASE							:   str						    =     config.hidden_size
       SCREAMING_SNAKE_CASE							:   str						    =     False
       SCREAMING_SNAKE_CASE							:   Any						    =     nn.Convad(self.channels       ,			config.num_labels       ,			kernel_size=1   )

       # PSP Module
       SCREAMING_SNAKE_CASE							:   Tuple						    =     UperNetPyramidPoolingModule(
           self.pool_scales       ,			self.in_channels[-1]       ,			self.channels       ,			align_corners=self.align_corners       ,			)
       SCREAMING_SNAKE_CASE							:   Tuple						    =     UperNetConvModule(
           self.in_channels[-1] + len(self.pool_scales   ) * self.channels       ,			self.channels       ,			kernel_size=3       ,			padding=1       ,			)
       # FPN Module
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     nn.ModuleList()
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     nn.ModuleList()
       for in_channels in self.in_channels[:-1]:  # skip the top layer
         SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     UperNetConvModule(UpperCAmelCase_       ,			self.channels       ,			kernel_size=1   )
         SCREAMING_SNAKE_CASE							:   Dict						    =     UperNetConvModule(self.channels       ,			self.channels       ,			kernel_size=3       ,			padding=1   )
         self.lateral_convs.append(UpperCAmelCase_   )
         self.fpn_convs.append(UpperCAmelCase_   )

       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     UperNetConvModule(
           len(self.in_channels   ) * self.channels       ,			self.channels       ,			kernel_size=3       ,			padding=1       ,			)


     def 					_A							(					self							:						Optional[int]   ):
       self.apply(self._init_weights   )


     def 					_A							(					self							:						Tuple       ,			UpperCAmelCase_							:						Union[str, Any]   ):
       if isinstance(UpperCAmelCase_       ,			nn.Convad   ):
         module.weight.data.normal_(mean=0.0       ,			std=self.config.initializer_range   )
         if module.bias is not None:
           module.bias.data.zero_()


     def 					_A							(					self							:						Tuple       ,			UpperCAmelCase_							:						str   ):
       SCREAMING_SNAKE_CASE							:   Any						    =     inputs[-1]
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     [x]
       psp_outs.extend(self.psp_modules(UpperCAmelCase_   )   )
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     torch.cat(UpperCAmelCase_       ,			dim=1   )
       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     self.bottleneck(UpperCAmelCase_   )

       return output






     def 					_A							(					self							:						Dict       ,			UpperCAmelCase_							:						torch.Tensor   ):
       # build laterals
       SCREAMING_SNAKE_CASE							:   Tuple						    =     [lateral_conv(encoder_hidden_states[i]   ) for i, lateral_conv in enumerate(self.lateral_convs   )]

       laterals.append(self.psp_forward(UpperCAmelCase_   )   )

       # build top-down path
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     len(UpperCAmelCase_   )
       for i in range(used_backbone_levels - 1       ,			0       ,			-1   ):
         SCREAMING_SNAKE_CASE							:   Optional[int]						    =     laterals[i - 1].shape[2:]
         SCREAMING_SNAKE_CASE							:   List[str]						    =     laterals[i - 1] + nn.functional.interpolate(
             laterals[i]       ,			size=UpperCAmelCase_       ,			mode="bilinear"       ,			align_corners=self.align_corners   )

       # build outputs
       SCREAMING_SNAKE_CASE							:   Any						    =     [self.fpn_convs[i](laterals[i]   ) for i in range(used_backbone_levels - 1   )]
       # append psp feature
       fpn_outs.append(laterals[-1]   )

       for i in range(used_backbone_levels - 1       ,			0       ,			-1   ):
         SCREAMING_SNAKE_CASE							:   List[Any]						    =     nn.functional.interpolate(
             fpn_outs[i]       ,			size=fpn_outs[0].shape[2:]       ,			mode="bilinear"       ,			align_corners=self.align_corners   )
       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     torch.cat(UpperCAmelCase_       ,			dim=1   )
       SCREAMING_SNAKE_CASE							:   Tuple						    =     self.fpn_bottleneck(UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     self.classifier(UpperCAmelCase_   )

       return output





class 			SCREAMING_SNAKE_CASE      (      nn.Module       ):
     '''simple docstring'''


     def __init__(					self							:						List[str]       ,			UpperCAmelCase_							:						str       ,			UpperCAmelCase_							:						int = 2       ,			UpperCAmelCase_							:						int = 3       ,			UpperCAmelCase_							:						Union[int, Tuple[int, int]] = 1   ):
       super().__init__()

       SCREAMING_SNAKE_CASE							:   int						    =     config
       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     config.auxiliary_in_channels
       SCREAMING_SNAKE_CASE							:   List[str]						    =     config.auxiliary_channels
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     config.auxiliary_num_convs
       SCREAMING_SNAKE_CASE							:   Tuple						    =     config.auxiliary_concat_input
       SCREAMING_SNAKE_CASE							:   Optional[int]						    =     in_index

       SCREAMING_SNAKE_CASE							:   List[Any]						    =     (kernel_size // 2) * dilation
       SCREAMING_SNAKE_CASE							:   int						    =     []
       convs.append(
           UperNetConvModule(
               self.in_channels       ,			self.channels       ,			kernel_size=UpperCAmelCase_       ,			padding=UpperCAmelCase_       ,			dilation=UpperCAmelCase_   )   )
       for i in range(self.num_convs - 1   ):
         convs.append(
             UperNetConvModule(
                 self.channels       ,			self.channels       ,			kernel_size=UpperCAmelCase_       ,			padding=UpperCAmelCase_       ,			dilation=UpperCAmelCase_   )   )
       if self.num_convs == 0:
         SCREAMING_SNAKE_CASE							:   Optional[int]						    =     nn.Identity()
       else:
         SCREAMING_SNAKE_CASE							:   List[str]						    =     nn.Sequential(*UpperCAmelCase_   )
       if self.concat_input:
         SCREAMING_SNAKE_CASE							:   Dict						    =     UperNetConvModule(
             self.in_channels + self.channels       ,			self.channels       ,			kernel_size=UpperCAmelCase_       ,			padding=kernel_size // 2   )

       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     nn.Convad(self.channels       ,			config.num_labels       ,			kernel_size=1   )


     def 					_A							(					self							:						Optional[int]   ):
       self.apply(self._init_weights   )


     def 					_A							(					self							:						int       ,			UpperCAmelCase_							:						Union[str, Any]   ):
       if isinstance(UpperCAmelCase_       ,			nn.Convad   ):
         module.weight.data.normal_(mean=0.0       ,			std=self.config.initializer_range   )
         if module.bias is not None:
           module.bias.data.zero_()






     def 					_A							(					self							:						Tuple       ,			UpperCAmelCase_							:						torch.Tensor   ):
       # just take the relevant feature maps
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     encoder_hidden_states[self.in_index]
       SCREAMING_SNAKE_CASE							:   Any						    =     self.convs(UpperCAmelCase_   )
       if self.concat_input:
         SCREAMING_SNAKE_CASE							:   str						    =     self.conv_cat(torch.cat([hidden_states, output]       ,			dim=1   )   )
       SCREAMING_SNAKE_CASE							:   int						    =     self.classifier(UpperCAmelCase_   )
       return output





class 			SCREAMING_SNAKE_CASE      (      lowerCAmelCase       ):
     '''simple docstring'''


     UpperCamelCase_				:		Tuple								=						UperNetConfig
     UpperCamelCase_				:		List[str]								=						'''pixel_values'''
     UpperCamelCase_				:		List[str]								=						True


     def 					_A							(					self							:						Tuple       ,			UpperCAmelCase_							:						Tuple   ):
       if isinstance(UpperCAmelCase_       ,			UpperCAmelCase_   ):
         module.backbone.init_weights()
         module.decode_head.init_weights()
         module.auxiliary_head.init_weights()


     def 					_A							(					self							:						Tuple   ):
       self.backbone.init_weights()
       self.decode_head.init_weights()
       self.auxiliary_head.init_weights()






     def 					_A							(					self							:						Dict       ,			UpperCAmelCase_							:						List[str]       ,			UpperCAmelCase_							:						Dict=False   ):
       if isinstance(UpperCAmelCase_       ,			UpperCAmelCase_   ):
         SCREAMING_SNAKE_CASE							:   List[Any]						    =     value





snake_case     					=		r"""
    Parameters:
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
    it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.
        config ([`UperNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
"""

snake_case     					=		r"""
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Padding will be ignored by default should you provide it. Pixel values can be obtained using
            [`AutoImageProcessor`]. See [`SegformerImageProcessor.__call__`] for details.
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers in case the backbone has them. See
            `attentions` under returned tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers of the backbone. See `hidden_states` under
            returned tensors for more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
"""


@add_start_docstrings(
    '''UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes.'''   ,		lowerCAmelCase   ,		)
class 			SCREAMING_SNAKE_CASE      (      lowerCAmelCase       ):
     '''simple docstring'''


     def __init__(					self							:						Any       ,			UpperCAmelCase_							:						Any   ):
       super().__init__(UpperCAmelCase_   )

       SCREAMING_SNAKE_CASE							:   List[str]						    =     AutoBackbone.from_config(config.backbone_config   )

       # Semantic segmentation head(s)
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     UperNetHead(UpperCAmelCase_       ,			in_channels=self.backbone.channels   )
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     UperNetFCNHead(UpperCAmelCase_   ) if config.use_auxiliary_head else None

       # Initialize weights and apply final processing
       self.post_init()






     @add_start_docstrings_to_model_forward(UPERNET_INPUTS_DOCSTRING.format("batch_size, sequence_length"   )   )
     @replace_return_docstrings(output_type=UpperCAmelCase_       ,			config_class=_CONFIG_FOR_DOC   )
     def 					_A							(					self							:						Union[str, Any]       ,			UpperCAmelCase_							:						Optional[torch.Tensor] = None       ,			UpperCAmelCase_							:						Optional[bool] = None       ,			UpperCAmelCase_							:						Optional[bool] = None       ,			UpperCAmelCase_							:						Optional[torch.Tensor] = None       ,			UpperCAmelCase_							:						Optional[bool] = None       ,			):
       SCREAMING_SNAKE_CASE							:   int						    =     return_dict if return_dict is not None else self.config.use_return_dict
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     (
           output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
       )
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     output_attentions if output_attentions is not None else self.config.output_attentions

       SCREAMING_SNAKE_CASE							:   Tuple						    =     self.backbone.forward_with_filtered_kwargs(
           UpperCAmelCase_       ,			output_hidden_states=UpperCAmelCase_       ,			output_attentions=UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   List[str]						    =     outputs.feature_maps

       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     self.decode_head(UpperCAmelCase_   )
       SCREAMING_SNAKE_CASE							:   str						    =     nn.functional.interpolate(UpperCAmelCase_       ,			size=pixel_values.shape[2:]       ,			mode="bilinear"       ,			align_corners=UpperCAmelCase_   )

       SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     None
       if self.auxiliary_head is not None:
         SCREAMING_SNAKE_CASE							:   Dict						    =     self.auxiliary_head(UpperCAmelCase_   )
         SCREAMING_SNAKE_CASE							:   int						    =     nn.functional.interpolate(
             UpperCAmelCase_       ,			size=pixel_values.shape[2:]       ,			mode="bilinear"       ,			align_corners=UpperCAmelCase_   )

       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     None
       if labels is not None:
         if self.config.num_labels == 1:
           raise ValueError("The number of labels should be greater than one"   )
         else:
           # compute weighted loss
           SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     CrossEntropyLoss(ignore_index=self.config.loss_ignore_index   )
           SCREAMING_SNAKE_CASE							:   Dict						    =     loss_fct(UpperCAmelCase_       ,			UpperCAmelCase_   )
           SCREAMING_SNAKE_CASE							:   int						    =     loss_fct(UpperCAmelCase_       ,			UpperCAmelCase_   )
           SCREAMING_SNAKE_CASE							:   Optional[Any]						    =     main_loss + self.config.auxiliary_loss_weight * auxiliary_loss

       if not return_dict:
         if output_hidden_states:
           SCREAMING_SNAKE_CASE							:   Any						    =     (logits,) + outputs[1:]
         else:
           SCREAMING_SNAKE_CASE							:   Any						    =     (logits,) + outputs[2:]
         return ((loss,) + output) if loss is not None else output

       return SemanticSegmenterOutput(
           loss=UpperCAmelCase_       ,			logits=UpperCAmelCase_       ,			hidden_states=outputs.hidden_states       ,			attentions=outputs.attentions       ,			)







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


_lowerCAmelCase       =		get_tests_dir("fixtures/spiece.model")
@require_sentencepiece
@require_tokenizers
class     lowerCAmelCase_     (       __lowercase,  unittest.TestCase ):
							UpperCAmelCase				   =     DebertaVaTokenizer
							UpperCAmelCase				   =     DebertaVaTokenizerFast
							UpperCAmelCase				   =     True
							UpperCAmelCase				   =     True







							def  UpperCamelCase_						(   self      :     List[Any]		):
												super().setUp()

												# We have a SentencePiece fixture for testing
												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			unk_token='''<unk>'''		)
												tokenizer.save_pretrained(self.tmpdirname		)







							def  UpperCamelCase_						(   self      :     Dict ,			_A      :     Union[str, Any]		):
												_UpperCamelCase			     =     '''this is a test'''
												_UpperCamelCase			     =     '''this is a test'''
												return input_text, output_text







							def  UpperCamelCase_						(   self      :     Optional[Any]		):
												_UpperCamelCase			     =     '''<pad>'''
												_UpperCamelCase			     =     0

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







							def  UpperCamelCase_						(   self      :     Any		):
												_UpperCamelCase			     =     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		) ,			3_0001		)







							def  UpperCamelCase_						(   self      :     List[Any]		):
												self.assertEqual(self.get_tokenizer().vocab_size ,			3_0000		)







							def  UpperCamelCase_						(   self      :     List[str]		):
												# fmt: off
												_UpperCamelCase			     =     ''' \tHeLLo!how  \n Are yoU?  '''
												_UpperCamelCase			     =     ['''▁hello''', '''!''', '''how''', '''▁are''', '''▁you''', '''?''']
												# fmt: on

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			do_lower_case=_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			do_lower_case=_A		)
												_UpperCamelCase			     =     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  UpperCamelCase_						(   self      :     Dict		):
												pass







							@unittest.skip('''There is an inconsistency between slow and fast tokenizer due to a bug in the fast one.'''		)
							def  UpperCamelCase_						(   self      :     Optional[Any]		):
												pass







							def  UpperCamelCase_						(   self      :     Dict		):
												# fmt: off
												_UpperCamelCase			     =     '''I was born in 92000, and this is falsé.'''
												_UpperCamelCase			     =     ['''▁''', '''<unk>''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', '''▁''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''▁''', '''.''', ]
												# fmt: on

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     List[Any]		):
												# fmt: off
												_UpperCamelCase			     =     '''I was born in 92000, and this is falsé.'''
												_UpperCamelCase			     =     ['''▁i''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', '''▁''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''▁''', '''.''', ]
												# fmt: on

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)
												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A ,			add_special_tokens=_A		)		)
												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     Dict		):
												# fmt: off
												_UpperCamelCase			     =     '''I was born in 92000, and this is falsé.'''
												_UpperCamelCase			     =     ['''▁i''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''.''', ]
												# fmt: on

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     int		):
												# fmt: off
												_UpperCamelCase			     =     '''I was born in 92000, and this is falsé.'''
												_UpperCamelCase			     =     ['''▁''', '''<unk>''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', '''▁''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''▁''', '''.''', ]
												# fmt: on

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     Tuple		):
												# fmt: off
												_UpperCamelCase			     =     ''' \tHeLLo!how  \n Are yoU?  '''
												_UpperCamelCase			     =     ['''▁''', '''<unk>''', '''e''', '''<unk>''', '''o''', '''!''', '''how''', '''▁''', '''<unk>''', '''re''', '''▁yo''', '''<unk>''', '''?''']
												# fmt: on

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			do_lower_case=_A ,			split_by_punct=_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A ,			add_special_tokens=_A		)		)

												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     List[str]		):
												_UpperCamelCase			     =     self.get_tokenizer()
												_UpperCamelCase			     =     self.get_rust_tokenizer()

												_UpperCamelCase			     =     '''I was born in 92000, and this is falsé.'''

												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(tokenizer.encode(_A ,			add_special_tokens=_A		)		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_A ,			add_special_tokens=_A		)		)
												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     tokenizer.encode(_A ,			add_special_tokens=_A		)
												_UpperCamelCase			     =     rust_tokenizer.encode(_A ,			add_special_tokens=_A		)
												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     self.get_rust_tokenizer()
												_UpperCamelCase			     =     tokenizer.encode(_A		)
												_UpperCamelCase			     =     rust_tokenizer.encode(_A		)
												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     Dict		):
												_UpperCamelCase			     =     '''This is a test'''
												_UpperCamelCase			     =     [13, 1, 4398, 25, 21, 1289]
												_UpperCamelCase			     =     ['''▁''', '''T''', '''his''', '''▁is''', '''▁a''', '''▁test''']
												_UpperCamelCase			     =     ['''▁''', '''<unk>''', '''his''', '''▁is''', '''▁a''', '''▁test''']

												_UpperCamelCase			     =     DebertaVaTokenizer(_A ,			keep_accents=_A		)
												_UpperCamelCase			     =     DebertaVaTokenizerFast(_A ,			keep_accents=_A		)

												_UpperCamelCase			     =     tokenizer.encode(_A ,			add_special_tokens=_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     tokenizer.tokenize(_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(_A		)
												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     rust_tokenizer.encode(_A ,			add_special_tokens=_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     rust_tokenizer.tokenize(_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(_A		)
												self.assertListEqual(_A ,			_A		)

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

												_UpperCamelCase			     =     tokenizer.encode(_A ,			add_special_tokens=_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     tokenizer.tokenize(_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     tokenizer.convert_ids_to_tokens(_A		)
												self.assertListEqual(_A ,			_A		)

												_UpperCamelCase			     =     rust_tokenizer.encode(_A ,			add_special_tokens=_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     rust_tokenizer.tokenize(_A		)
												self.assertListEqual(_A ,			_A		)
												_UpperCamelCase			     =     rust_tokenizer.convert_ids_to_tokens(_A		)
												self.assertListEqual(_A ,			_A		)







							def  UpperCamelCase_						(   self      :     Any		):
												_UpperCamelCase			     =     DebertaVaTokenizer(_A		)

												_UpperCamelCase			     =     tokenizer.encode('''sequence builders'''		)
												_UpperCamelCase			     =     tokenizer.encode('''multi-sequence build'''		)

												_UpperCamelCase			     =     tokenizer.build_inputs_with_special_tokens(_A		)
												_UpperCamelCase			     =     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  UpperCamelCase_						(   self      :     Optional[Any]		):
												# fmt: off
												_UpperCamelCase			     =     {'''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=_A ,			model_name='''microsoft/deberta-v2-xlarge''' ,			revision='''ad6e42c1532ddf3a15c39246b63f5559d558b670''' ,			)
