
from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


UpperCamelCase_   	=	logging.get_logger(__name__)

# General docstring
UpperCamelCase_   	=	"RegNetConfig"

# Base docstring
UpperCamelCase_   	=	"facebook/regnet-y-040"
UpperCamelCase_   	=	[1, 1_0_8_8, 7, 7]

# Image classification docstring
UpperCamelCase_   	=	"facebook/regnet-y-040"
UpperCamelCase_   	=	"tabby, tabby cat"

UpperCamelCase_   	=	[
    "facebook/regnet-y-040",
    # See all regnet models at https://huggingface.co/models?filter=regnet
]

class       a		(   nn.Module					):







							def __init__(						self  :  int      ,				snake_case__  :  int      ,				snake_case__  :  int      ,				snake_case__  :  int = 3      ,				snake_case__  :  int = 1      ,				snake_case__  :  int = 1      ,				snake_case__  :  Optional[str] = "relu"      ,				):
								"""simple docstring"""







								super().__init__()
								__lowerCAmelCase         =							nn.Convad(
								    snake_case__      ,				snake_case__      ,				kernel_size=snake_case__      ,				stride=snake_case__      ,				padding=kernel_size // 2      ,				groups=snake_case__      ,				bias=snake_case__      ,				)
								__lowerCAmelCase         =							nn.BatchNormad(snake_case__ )
								__lowerCAmelCase         =							ACTaFN[activation] if activation is not None else nn.Identity()







							def       UpperCAmelCase__					(						self  :  List[Any]      ,				snake_case__  :  Optional[Any] ):
								"""simple docstring"""







								__lowerCAmelCase         =							self.convolution(snake_case__ )
								__lowerCAmelCase         =							self.normalization(snake_case__ )
								__lowerCAmelCase         =							self.activation(snake_case__ )
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  List[str]      ,				snake_case__  :  RegNetConfig ):
								"""simple docstring"""







								super().__init__()
								__lowerCAmelCase         =							RegNetConvLayer(
								    config.num_channels      ,				config.embedding_size      ,				kernel_size=3      ,				stride=2      ,				activation=config.hidden_act )
								__lowerCAmelCase         =							config.num_channels







							def       UpperCAmelCase__					(						self  :  Optional[int]      ,				snake_case__  :  Dict ):
								"""simple docstring"""







								__lowerCAmelCase         =							pixel_values.shape[1]
								if num_channels != self.num_channels:
									raise ValueError(
									    "Make sure that the channel dimension of the pixel values match with the one set in the configuration." )
								__lowerCAmelCase         =							self.embedder(snake_case__ )
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  str      ,				snake_case__  :  int      ,				snake_case__  :  int      ,				snake_case__  :  int = 2 ):
								"""simple docstring"""







								super().__init__()
								__lowerCAmelCase         =							nn.Convad(snake_case__      ,				snake_case__      ,				kernel_size=1      ,				stride=snake_case__      ,				bias=snake_case__ )
								__lowerCAmelCase         =							nn.BatchNormad(snake_case__ )







							def       UpperCAmelCase__					(						self  :  Tuple      ,				snake_case__  :  Tensor ):
								"""simple docstring"""







								__lowerCAmelCase         =							self.convolution(snake_case__ )
								__lowerCAmelCase         =							self.normalization(snake_case__ )
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  Tuple      ,				snake_case__  :  int      ,				snake_case__  :  int ):
								"""simple docstring"""







								super().__init__()

								__lowerCAmelCase         =							nn.AdaptiveAvgPoolad((1, 1) )
								__lowerCAmelCase         =							nn.Sequential(
								    nn.Convad(snake_case__      ,				snake_case__      ,				kernel_size=1 )      ,				nn.ReLU()      ,				nn.Convad(snake_case__      ,				snake_case__      ,				kernel_size=1 )      ,				nn.Sigmoid()      ,				)







							def       UpperCAmelCase__					(						self  :  Any      ,				snake_case__  :  str ):
								"""simple docstring"""







								__lowerCAmelCase         =							self.pooler(snake_case__ )
								__lowerCAmelCase         =							self.attention(snake_case__ )
								__lowerCAmelCase         =							hidden_state * attention
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  int      ,				snake_case__  :  RegNetConfig      ,				snake_case__  :  int      ,				snake_case__  :  int      ,				snake_case__  :  int = 1 ):
								"""simple docstring"""







								super().__init__()
								__lowerCAmelCase         =							in_channels != out_channels or stride != 1
								__lowerCAmelCase         =							max(1      ,				out_channels // config.groups_width )
								__lowerCAmelCase         =							(
								    RegNetShortCut(snake_case__      ,				snake_case__      ,				stride=snake_case__ ) if should_apply_shortcut else nn.Identity()
								)
								__lowerCAmelCase         =							nn.Sequential(
								    RegNetConvLayer(snake_case__      ,				snake_case__      ,				kernel_size=1      ,				activation=config.hidden_act )      ,				RegNetConvLayer(snake_case__      ,				snake_case__      ,				stride=snake_case__      ,				groups=snake_case__      ,				activation=config.hidden_act )      ,				RegNetConvLayer(snake_case__      ,				snake_case__      ,				kernel_size=1      ,				activation=snake_case__ )      ,				)
								__lowerCAmelCase         =							ACTaFN[config.hidden_act]







							def       UpperCAmelCase__					(						self  :  str      ,				snake_case__  :  Optional[int] ):
								"""simple docstring"""







								__lowerCAmelCase         =							hidden_state
								__lowerCAmelCase         =							self.layer(snake_case__ )
								__lowerCAmelCase         =							self.shortcut(snake_case__ )
								hidden_state += residual
								__lowerCAmelCase         =							self.activation(snake_case__ )
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  str      ,				snake_case__  :  RegNetConfig      ,				snake_case__  :  int      ,				snake_case__  :  int      ,				snake_case__  :  int = 1 ):
								"""simple docstring"""







								super().__init__()
								__lowerCAmelCase         =							in_channels != out_channels or stride != 1
								__lowerCAmelCase         =							max(1      ,				out_channels // config.groups_width )
								__lowerCAmelCase         =							(
								    RegNetShortCut(snake_case__      ,				snake_case__      ,				stride=snake_case__ ) if should_apply_shortcut else nn.Identity()
								)
								__lowerCAmelCase         =							nn.Sequential(
								    RegNetConvLayer(snake_case__      ,				snake_case__      ,				kernel_size=1      ,				activation=config.hidden_act )      ,				RegNetConvLayer(snake_case__      ,				snake_case__      ,				stride=snake_case__      ,				groups=snake_case__      ,				activation=config.hidden_act )      ,				RegNetSELayer(snake_case__      ,				reduced_channels=int(round(in_channels / 4 ) ) )      ,				RegNetConvLayer(snake_case__      ,				snake_case__      ,				kernel_size=1      ,				activation=snake_case__ )      ,				)
								__lowerCAmelCase         =							ACTaFN[config.hidden_act]







							def       UpperCAmelCase__					(						self  :  Optional[int]      ,				snake_case__  :  str ):
								"""simple docstring"""







								__lowerCAmelCase         =							hidden_state
								__lowerCAmelCase         =							self.layer(snake_case__ )
								__lowerCAmelCase         =							self.shortcut(snake_case__ )
								hidden_state += residual
								__lowerCAmelCase         =							self.activation(snake_case__ )
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  Union[str, Any]      ,				snake_case__  :  RegNetConfig      ,				snake_case__  :  int      ,				snake_case__  :  int      ,				snake_case__  :  int = 2      ,				snake_case__  :  int = 2      ,				):
								"""simple docstring"""







								super().__init__()

								__lowerCAmelCase         =							RegNetXLayer if config.layer_type == "x" else RegNetYLayer

								__lowerCAmelCase         =							nn.Sequential(
								    # downsampling is done in the first layer with stride of 2
								    layer(
								        snake_case__      ,				snake_case__      ,				snake_case__      ,				stride=snake_case__      ,				)      ,				*[layer(snake_case__      ,				snake_case__      ,				snake_case__ ) for _ in range(depth - 1 )]      ,				)







							def       UpperCAmelCase__					(						self  :  Union[str, Any]      ,				snake_case__  :  Tuple ):
								"""simple docstring"""







								__lowerCAmelCase         =							self.layers(snake_case__ )
								return hidden_state

class       a		(   nn.Module					):







							def __init__(						self  :  int      ,				snake_case__  :  RegNetConfig ):
								"""simple docstring"""







								super().__init__()
								__lowerCAmelCase         =							nn.ModuleList([] )
								# based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
								self.stages.append(
								    RegNetStage(
								        snake_case__      ,				config.embedding_size      ,				config.hidden_sizes[0]      ,				stride=2 if config.downsample_in_first_stage else 1      ,				depth=config.depths[0]      ,				) )
								__lowerCAmelCase         =							zip(config.hidden_sizes      ,				config.hidden_sizes[1:] )
								for (in_channels, out_channels), depth in zip(snake_case__      ,				config.depths[1:] ):
									self.stages.append(RegNetStage(snake_case__      ,				snake_case__      ,				snake_case__      ,				depth=snake_case__ ) )







							def       UpperCAmelCase__					(						self  :  List[str]      ,				snake_case__  :  Tensor      ,				snake_case__  :  bool = False      ,				snake_case__  :  bool = True ):
								"""simple docstring"""







								__lowerCAmelCase         =							() if output_hidden_states else None

								for stage_module in self.stages:
									if output_hidden_states:
										__lowerCAmelCase         =							hidden_states + (hidden_state,)

									__lowerCAmelCase         =							stage_module(snake_case__ )

								if output_hidden_states:
									__lowerCAmelCase         =							hidden_states + (hidden_state,)

								if not return_dict:
									return tuple(v for v in [hidden_state, hidden_states] if v is not None )

								return BaseModelOutputWithNoAttention(last_hidden_state=snake_case__      ,				hidden_states=snake_case__ )

class       a		(   __UpperCAmelCase					):
							lowercase_		:						int   							=  RegNetConfig
							lowercase_		:						List[str]   							=  'regnet'
							lowercase_		:						List[Any]   							=  'pixel_values'
							lowercase_		:						Dict   							=  True







							def       UpperCAmelCase__					(						self  :  Optional[Any]      ,				snake_case__  :  int ):
								"""simple docstring"""







								if isinstance(snake_case__      ,				nn.Convad ):
									nn.init.kaiming_normal_(module.weight      ,				mode="fan_out"      ,				nonlinearity="relu" )
								elif isinstance(snake_case__      ,				(nn.BatchNormad, nn.GroupNorm) ):
									nn.init.constant_(module.weight      ,				1 )
									nn.init.constant_(module.bias      ,				0 )







							def       UpperCAmelCase__					(						self  :  Tuple      ,				snake_case__  :  str      ,				snake_case__  :  Union[str, Any]=False ):
								"""simple docstring"""







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

UpperCamelCase_   	=	R"\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`ConvNextImageProcessor.__call__`] for details.\n\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.\n"

@add_start_docstrings(
    'The bare RegNet model outputting raw features without any specific head on top.'      ,	__UpperCAmelCase      ,	)
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class       a		(   __UpperCAmelCase					):







							def __init__(						self  :  Optional[Any]      ,				snake_case__  :  int ):
								"""simple docstring"""







								super().__init__(snake_case__ )
								__lowerCAmelCase         =							config
								__lowerCAmelCase         =							RegNetEmbeddings(snake_case__ )
								__lowerCAmelCase         =							RegNetEncoder(snake_case__ )
								__lowerCAmelCase         =							nn.AdaptiveAvgPoolad((1, 1) )
								# Initialize weights and apply final processing
								self.post_init()







							@add_start_docstrings_to_model_forward(snake_case__ )
							@add_code_sample_docstrings(
							    checkpoint=_CHECKPOINT_FOR_DOC      ,				output_type=snake_case__      ,				config_class=_CONFIG_FOR_DOC      ,				modality="vision"      ,				expected_output=_EXPECTED_OUTPUT_SHAPE      ,				)
							def       UpperCAmelCase__					(						self  :  List[Any]      ,				snake_case__  :  Tensor      ,				snake_case__  :  Optional[bool] = None      ,				snake_case__  :  Optional[bool] = None ):
								"""simple docstring"""







								__lowerCAmelCase         =							(
								    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
								)
								__lowerCAmelCase         =							return_dict if return_dict is not None else self.config.use_return_dict

								__lowerCAmelCase         =							self.embedder(snake_case__ )

								__lowerCAmelCase         =							self.encoder(
								    snake_case__      ,				output_hidden_states=snake_case__      ,				return_dict=snake_case__ )

								__lowerCAmelCase         =							encoder_outputs[0]

								__lowerCAmelCase         =							self.pooler(snake_case__ )

								if not return_dict:
									return (last_hidden_state, pooled_output) + encoder_outputs[1:]

								return BaseModelOutputWithPoolingAndNoAttention(
								    last_hidden_state=snake_case__      ,				pooler_output=snake_case__      ,				hidden_states=encoder_outputs.hidden_states      ,				)

@add_start_docstrings(
    '\n    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    '      ,	__UpperCAmelCase      ,	)
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class       a		(   __UpperCAmelCase					):







							def __init__(						self  :  Optional[Any]      ,				snake_case__  :  str ):
								"""simple docstring"""







								super().__init__(snake_case__ )
								__lowerCAmelCase         =							config.num_labels
								__lowerCAmelCase         =							RegNetModel(snake_case__ )
								# classification head
								__lowerCAmelCase         =							nn.Sequential(
								    nn.Flatten()      ,				nn.Linear(config.hidden_sizes[-1]      ,				config.num_labels ) if config.num_labels > 0 else nn.Identity()      ,				)
								# initialize weights and apply final processing
								self.post_init()







							@add_start_docstrings_to_model_forward(snake_case__ )
							@add_code_sample_docstrings(
							    checkpoint=_IMAGE_CLASS_CHECKPOINT      ,				output_type=snake_case__      ,				config_class=_CONFIG_FOR_DOC      ,				expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT      ,				)
							def       UpperCAmelCase__					(						self  :  Any      ,				snake_case__  :  Optional[torch.FloatTensor] = None      ,				snake_case__  :  Optional[torch.LongTensor] = None      ,				snake_case__  :  Optional[bool] = None      ,				snake_case__  :  Optional[bool] = None      ,				):
								"""simple docstring"""







								__lowerCAmelCase         =							return_dict if return_dict is not None else self.config.use_return_dict

								__lowerCAmelCase         =							self.regnet(snake_case__      ,				output_hidden_states=snake_case__      ,				return_dict=snake_case__ )

								__lowerCAmelCase         =							outputs.pooler_output if return_dict else outputs[1]

								__lowerCAmelCase         =							self.classifier(snake_case__ )

								__lowerCAmelCase         =							None

								if labels is not None:
									if self.config.problem_type is None:
										if self.num_labels == 1:
											__lowerCAmelCase         =							"regression"
										elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
											__lowerCAmelCase         =							"single_label_classification"
										else:
											__lowerCAmelCase         =							"multi_label_classification"
									if self.config.problem_type == "regression":
										__lowerCAmelCase         =							MSELoss()
										if self.num_labels == 1:
											__lowerCAmelCase         =							loss_fct(logits.squeeze()      ,				labels.squeeze() )
										else:
											__lowerCAmelCase         =							loss_fct(snake_case__      ,				snake_case__ )
									elif self.config.problem_type == "single_label_classification":
										__lowerCAmelCase         =							CrossEntropyLoss()
										__lowerCAmelCase         =							loss_fct(logits.view(-1      ,				self.num_labels )      ,				labels.view(-1 ) )
									elif self.config.problem_type == "multi_label_classification":
										__lowerCAmelCase         =							BCEWithLogitsLoss()
										__lowerCAmelCase         =							loss_fct(snake_case__      ,				snake_case__ )

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

								return ImageClassifierOutputWithNoAttention(loss=snake_case__      ,				logits=snake_case__      ,				hidden_states=outputs.hidden_states )








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


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

@require_sentencepiece
@require_tokenizers
class       a		(   __UpperCAmelCase      ,	unittest.TestCase					):
							lowercase_		:						Union[str, Any]   							=  DebertaVaTokenizer
							lowercase_		:						List[str]   							=  DebertaVaTokenizerFast
							lowercase_		:						str   							=  True
							lowercase_		:						List[Any]   							=  True







							def       UpperCAmelCase__					(						self  :  Optional[Any] ):
								"""simple docstring"""







								super().setUp()

								# We have a SentencePiece fixture for testing
								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				unk_token="<unk>" )
								tokenizer.save_pretrained(self.tmpdirname )







							def       UpperCAmelCase__					(						self  :  str      ,				snake_case__  :  Dict ):
								"""simple docstring"""







								__lowerCAmelCase         =							"this is a test"
								__lowerCAmelCase         =							"this is a test"
								return input_text, output_text







							def       UpperCAmelCase__					(						self  :  int ):
								"""simple docstring"""







								__lowerCAmelCase         =							"<pad>"
								__lowerCAmelCase         =							0

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







							def       UpperCAmelCase__					(						self  :  Any ):
								"""simple docstring"""







								__lowerCAmelCase         =							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(snake_case__ )      ,				30_001 )







							def       UpperCAmelCase__					(						self  :  Tuple ):
								"""simple docstring"""







								self.assertEqual(self.get_tokenizer().vocab_size      ,				30_000 )







							def       UpperCAmelCase__					(						self  :  List[str] ):
								"""simple docstring"""







								__lowerCAmelCase         =							" \tHeLLo!how  \n Are yoU?  "
								__lowerCAmelCase         =							["▁hello", "!", "how", "▁are", "▁you", "?"]
								# fmt: on

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				do_lower_case=snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				do_lower_case=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )







							@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  :  List[str] ):
								"""simple docstring"""







								pass







							def       UpperCAmelCase__					(						self  :  Any ):
								"""simple docstring"""







								__lowerCAmelCase         =							"I was born in 92000, and this is falsé."
								__lowerCAmelCase         =							["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
								# fmt: on

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Tuple ):
								"""simple docstring"""







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

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )
								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )
								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Optional[int] ):
								"""simple docstring"""







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

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  int ):
								"""simple docstring"""







								__lowerCAmelCase         =							"I was born in 92000, and this is falsé."
								__lowerCAmelCase         =							["▁", "<unk>", "▁was", "▁born", "▁in", "▁9", "2000", "▁", ",", "▁and", "▁this", "▁is", "▁fal", "s", "<unk>", "▁", ".", ]
								# fmt: on

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Tuple ):
								"""simple docstring"""







								__lowerCAmelCase         =							" \tHeLLo!how  \n Are yoU?  "
								__lowerCAmelCase         =							["▁", "<unk>", "e", "<unk>", "o", "!", "how", "▁", "<unk>", "re", "▁yo", "<unk>", "?"]
								# fmt: on

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				do_lower_case=snake_case__      ,				split_by_punct=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )

								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Optional[int] ):
								"""simple docstring"""







								__lowerCAmelCase         =							self.get_tokenizer()
								__lowerCAmelCase         =							self.get_rust_tokenizer()

								__lowerCAmelCase         =							"I was born in 92000, and this is falsé."

								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ ) )
								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							self.get_rust_tokenizer()
								__lowerCAmelCase         =							tokenizer.encode(snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.encode(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Optional[int] ):
								"""simple docstring"""







								__lowerCAmelCase         =							"This is a test"
								__lowerCAmelCase         =							[13, 1, 4_398, 25, 21, 1_289]
								__lowerCAmelCase         =							["▁", "T", "his", "▁is", "▁a", "▁test"]
								__lowerCAmelCase         =							["▁", "<unk>", "his", "▁is", "▁a", "▁test"]

								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__      ,				keep_accents=snake_case__ )
								__lowerCAmelCase         =							DebertaVaTokenizerFast(snake_case__      ,				keep_accents=snake_case__ )

								__lowerCAmelCase         =							tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							tokenizer.tokenize(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.tokenize(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )

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

								__lowerCAmelCase         =							tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							tokenizer.tokenize(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							tokenizer.convert_ids_to_tokens(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )

								__lowerCAmelCase         =							rust_tokenizer.encode(snake_case__      ,				add_special_tokens=snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.tokenize(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )
								__lowerCAmelCase         =							rust_tokenizer.convert_ids_to_tokens(snake_case__ )
								self.assertListEqual(snake_case__      ,				snake_case__ )







							def       UpperCAmelCase__					(						self  :  Any ):
								"""simple docstring"""







								__lowerCAmelCase         =							DebertaVaTokenizer(snake_case__ )

								__lowerCAmelCase         =							tokenizer.encode("sequence builders" )
								__lowerCAmelCase         =							tokenizer.encode("multi-sequence build" )

								__lowerCAmelCase         =							tokenizer.build_inputs_with_special_tokens(snake_case__ )
								__lowerCAmelCase         =							tokenizer.build_inputs_with_special_tokens(snake_case__      ,				snake_case__ )

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







							@slow
							def       UpperCAmelCase__					(						self  :  Optional[int] ):
								"""simple docstring"""







								__lowerCAmelCase         =							{"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=snake_case__      ,				model_name="microsoft/deberta-v2-xlarge"      ,				revision="ad6e42c1532ddf3a15c39246b63f5559d558b670"      ,				)






