



import math
import os
import unittest

from transformers import MegatronBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
				import torch

				from transformers import (
				    MODEL_FOR_PRETRAINING_MAPPING,
				    MegatronBertForCausalLM,
				    MegatronBertForMaskedLM,
				    MegatronBertForMultipleChoice,
				    MegatronBertForNextSentencePrediction,
				    MegatronBertForPreTraining,
				    MegatronBertForQuestionAnswering,
				    MegatronBertForSequenceClassification,
				    MegatronBertForTokenClassification,
				    MegatronBertModel,
				)



class        lowerCAmelCase__					:


				def __init__(							self      :  List[Any]						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Optional[int]=13						, __UpperCamelCase      :  int=7						, __UpperCamelCase      :  List[Any]=True						, __UpperCamelCase      :  Union[str, Any]=True						, __UpperCamelCase      :  Dict=True						, __UpperCamelCase      :  str=True						, __UpperCamelCase      :  Optional[Any]=99						, __UpperCamelCase      :  List[str]=64						, __UpperCamelCase      :  Optional[int]=32						, __UpperCamelCase      :  Tuple=5						, __UpperCamelCase      :  int=4						, __UpperCamelCase      :  Any=37						, __UpperCamelCase      :  Optional[int]="gelu"						, __UpperCamelCase      :  int=0.1						, __UpperCamelCase      :  Union[str, Any]=0.1						, __UpperCamelCase      :  List[str]=512						, __UpperCamelCase      :  Any=16						, __UpperCamelCase      :  Optional[Any]=2						, __UpperCamelCase      :  Optional[int]=0.0_2						, __UpperCamelCase      :  int=3						, __UpperCamelCase      :  List[Any]=4						, __UpperCamelCase      :  List[str]=None						, )		->     List[Any]:
											A      						=    parent
											A      						=    batch_size
											A      						=    seq_length
											A      						=    is_training
											A      						=    use_input_mask
											A      						=    use_token_type_ids
											A      						=    use_labels
											A      						=    vocab_size
											A      						=    hidden_size
											A      						=    embedding_size
											A      						=    num_hidden_layers
											A      						=    num_attention_heads
											A      						=    intermediate_size
											A      						=    hidden_act
											A      						=    hidden_dropout_prob
											A      						=    attention_probs_dropout_prob
											A      						=    max_position_embeddings
											A      						=    type_vocab_size
											A      						=    type_sequence_label_size
											A      						=    initializer_range
											A      						=    num_labels
											A      						=    num_choices
											A      						=    scope


				def __UpperCamelCase						(							self      :  Dict       )		->     Optional[int]:
											A      						=    ids_tensor([self.batch_size, self.seq_length]						, self.vocab_size       )

											A      						=    None
											if self.use_input_mask:
																		A      						=    random_attention_mask([self.batch_size, self.seq_length]       )

											A      						=    None
											if self.use_token_type_ids:
																		A      						=    ids_tensor([self.batch_size, self.seq_length]						, self.type_vocab_size       )

											A      						=    None
											A      						=    None
											A      						=    None
											if self.use_labels:
																		A      						=    ids_tensor([self.batch_size]						, self.type_sequence_label_size       )
																		A      						=    ids_tensor([self.batch_size, self.seq_length]						, self.num_labels       )
																		A      						=    ids_tensor([self.batch_size]						, self.num_choices       )

											A      						=    self.get_config()

											return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


				def __UpperCamelCase						(							self      :  List[Any]       )		->     List[Any]:
											return MegatronBertConfig(
											    vocab_size=self.vocab_size						, hidden_size=self.hidden_size						, num_hidden_layers=self.num_hidden_layers						, num_attention_heads=self.num_attention_heads						, intermediate_size=self.intermediate_size						, embedding_size=self.embedding_size						, hidden_act=self.hidden_act						, hidden_dropout_prob=self.hidden_dropout_prob						, attention_probs_dropout_prob=self.attention_probs_dropout_prob						, max_position_embeddings=self.max_position_embeddings						, type_vocab_size=self.type_vocab_size						, is_decoder=__UpperCamelCase						, initializer_range=self.initializer_range						, )


				def __UpperCamelCase						(							self      :  Tuple						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Optional[Any]       )		->     Optional[int]:
											A      						=    MegatronBertModel(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(__UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase       )
											A      						=    model(__UpperCamelCase						, token_type_ids=__UpperCamelCase       )
											A      						=    model(__UpperCamelCase       )

											self.parent.assertEqual(result.last_hidden_state.shape						, (self.batch_size, self.seq_length, self.hidden_size)       )
											self.parent.assertEqual(result.pooler_output.shape						, (self.batch_size, self.hidden_size)       )


				def __UpperCamelCase						(							self      :  Optional[int]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Tuple						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Tuple       )		->     Union[str, Any]:
											A      						=    MegatronBertForMaskedLM(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(__UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.seq_length, self.vocab_size)       )


				def __UpperCamelCase						(							self      :  Optional[Any]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  Optional[Any]       )		->     int:
											A      						=    MegatronBertForCausalLM(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(__UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.seq_length, self.vocab_size)       )


				def __UpperCamelCase						(							self      :  List[Any]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Tuple						, __UpperCamelCase      :  List[str]       )		->     Any:
											A      						=    MegatronBertForNextSentencePrediction(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(
											    __UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase						, )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, 2)       )


				def __UpperCamelCase						(							self      :  List[Any]						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  List[Any]       )		->     Optional[Any]:
											A      						=    MegatronBertForPreTraining(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(
											    __UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase						, next_sentence_label=__UpperCamelCase						, )
											self.parent.assertEqual(result.prediction_logits.shape						, (self.batch_size, self.seq_length, self.vocab_size)       )
											self.parent.assertEqual(result.seq_relationship_logits.shape						, (self.batch_size, 2)       )


				def __UpperCamelCase						(							self      :  List[Any]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  List[Any]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  int       )		->     Union[str, Any]:
											A      						=    MegatronBertForQuestionAnswering(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(
											    __UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, start_positions=__UpperCamelCase						, end_positions=__UpperCamelCase						, )
											self.parent.assertEqual(result.start_logits.shape						, (self.batch_size, self.seq_length)       )
											self.parent.assertEqual(result.end_logits.shape						, (self.batch_size, self.seq_length)       )


				def __UpperCamelCase						(							self      :  List[str]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  int       )		->     List[str]:
											A      						=    self.num_labels
											A      						=    MegatronBertForSequenceClassification(__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(__UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.num_labels)       )


				def __UpperCamelCase						(							self      :  Tuple						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  int						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  List[Any]       )		->     Tuple:
											A      						=    self.num_labels
											A      						=    MegatronBertForTokenClassification(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    model(__UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase       )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.seq_length, self.num_labels)       )


				def __UpperCamelCase						(							self      :  Optional[int]						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Union[str, Any]						, __UpperCamelCase      :  int						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  List[Any]       )		->     List[Any]:
											A      						=    self.num_choices
											A      						=    MegatronBertForMultipleChoice(config=__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.eval()
											A      						=    input_ids.unsqueeze(1       ).expand(-1						, self.num_choices						, -1       ).contiguous()
											A      						=    token_type_ids.unsqueeze(1       ).expand(-1						, self.num_choices						, -1       ).contiguous()
											A      						=    input_mask.unsqueeze(1       ).expand(-1						, self.num_choices						, -1       ).contiguous()
											A      						=    model(
											    __UpperCamelCase						, attention_mask=__UpperCamelCase						, token_type_ids=__UpperCamelCase						, labels=__UpperCamelCase						, )
											self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.num_choices)       )


				def __UpperCamelCase						(							self      :  Union[str, Any]       )		->     Dict:
											A      						=    self.prepare_config_and_inputs()
											(
											    (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   (
											    A
											)						,   
											)      						=    config_and_inputs
											A      						=    {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict





@require_torch
class        lowerCAmelCase__					(  _lowerCamelCase ,				_lowerCamelCase ,				unittest.TestCase       ):
				A_   :     Dict								=     (
				    (
				        MegatronBertModel,
				        MegatronBertForMaskedLM,
				        MegatronBertForCausalLM,
				        MegatronBertForMultipleChoice,
				        MegatronBertForNextSentencePrediction,
				        MegatronBertForPreTraining,
				        MegatronBertForQuestionAnswering,
				        MegatronBertForSequenceClassification,
				        MegatronBertForTokenClassification,
				    )
				    if is_torch_available()
				    else ()
				)
				A_   :     Optional[Any]								=     (
				    {
				        'feature-extraction': MegatronBertModel,
				        'fill-mask': MegatronBertForMaskedLM,
				        'question-answering': MegatronBertForQuestionAnswering,
				        'text-classification': MegatronBertForSequenceClassification,
				        'text-generation': MegatronBertForCausalLM,
				        'token-classification': MegatronBertForTokenClassification,
				        'zero-shot': MegatronBertForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				A_   :     Optional[int]								=     True
				# test_resize_embeddings = False
				A_   :     Union[str, Any]								=     False


				def __UpperCamelCase						(							self      :  List[str]						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  Tuple=False       )		->     Any:
											A      						=    super()._prepare_for_class(__UpperCamelCase						, __UpperCamelCase						, return_labels=__UpperCamelCase       )

											if return_labels:
																		if model_class in get_values(__UpperCamelCase       ):
																									A      						=    torch.zeros(
																									    (self.model_tester.batch_size, self.model_tester.seq_length)						, dtype=torch.long						, device=__UpperCamelCase       )
																									A      						=    torch.zeros(
																									    self.model_tester.batch_size						, dtype=torch.long						, device=__UpperCamelCase       )
											return inputs_dict


				def __UpperCamelCase						(							self      :  str       )		->     str:
											A      						=    MegatronBertModelTester(self       )
											A      						=    ConfigTester(self						, config_class=__UpperCamelCase						, hidden_size=37       )


				def __UpperCamelCase						(							self      :  Union[str, Any]       )		->     Tuple:
											self.config_tester.run_common_tests()


				def __UpperCamelCase						(							self      :  int       )		->     List[str]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_model(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Optional[int]       )		->     Union[str, Any]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_masked_lm(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Optional[Any]       )		->     str:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_multiple_choice(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  List[Any]       )		->     List[str]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_next_sequence_prediction(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  List[str]       )		->     Tuple:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_pretraining(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Any       )		->     Dict:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_question_answering(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Dict       )		->     List[Any]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_sequence_classification(*__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Union[str, Any]       )		->     List[str]:
											A      						=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_megatron_bert_for_token_classification(*__UpperCamelCase       )






def  lowerCamelCase_	(      lowerCAmelCase__	:	Union[str, Any]				)       ->							Optional[int]:

							'''simple docstring'''






							return torch.tensor(
							    lowerCAmelCase__			,	dtype=torch.long			,	device=lowerCAmelCase__			,	)


__snake_case     :Optional[Any]			       =1E-4



@require_torch
@require_sentencepiece
@require_tokenizers
class        lowerCAmelCase__					(  unittest.TestCase       ):


				@slow
				@unittest.skip('Model is not available.'       )
				def __UpperCamelCase						(							self      :  Optional[int]       )		->     str:
											A      						=    'nvidia/megatron-bert-uncased-345m'
											if "MYDIR" in os.environ:
																		A      						=    os.path.join(os.environ['MYDIR']						, __UpperCamelCase       )
											A      						=    MegatronBertModel.from_pretrained(__UpperCamelCase       )
											model.to(__UpperCamelCase       )
											model.half()
											A      						=    _long_tensor([[101, 7_110, 1_005, 1_056, 2_023, 11_333, 17_413, 1_029, 102]]       )
											with torch.no_grad():
																		A      						=    model(__UpperCamelCase       )[0]
											A      						=    torch.Size((1, 9, 1_024)       )
											self.assertEqual(output.shape						, __UpperCamelCase       )

											A      						=    [-0.6_0_4_0, -0.2_5_1_7, -0.1_0_2_5, 0.3_4_2_0, -0.6_7_5_8, -0.0_0_1_7, -0.1_0_8_9, -0.1_9_9_0, 0.5_7_2_8]
											for ii in range(3       ):
																		for jj in range(3       ):
																									A      						=    output[0, ii, jj]
																									A      						=    expected[3 * ii + jj]
																									A      						=    'ii={} jj={} a={} b={}'.format(__UpperCamelCase						, __UpperCamelCase						, __UpperCamelCase						, __UpperCamelCase       )
																									self.assertTrue(math.isclose(__UpperCamelCase						, __UpperCamelCase						, rel_tol=__UpperCamelCase						, abs_tol=__UpperCamelCase       )						, msg=__UpperCamelCase       )
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''' ,			)
