
import argparse
from typing import List

import evaluate
import numpy as np
import torch
from datasets import DatasetDict, load_dataset

# New Code #
# We'll be using StratifiedKFold for this example
from sklearn.model_selection import StratifiedKFold
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed

from accelerate import Accelerator, DistributedType


########################################################################
# This is a fully working simple example to use Accelerate,
# specifically showcasing how to perform Cross Validation,
# and builds off the `nlp_example.py` script.
#
# This example trains a Bert base model on GLUE MRPC
# in any of the following settings (with the same script):
#   - single CPU or single GPU
#   - multi GPUS (using PyTorch distributed mode)
#   - (multi) TPUs
#   - fp16 (mixed-precision) or fp32 (normal precision)
#
# To help focus on the differences in the code, building `DataLoaders`
# was refactored into its own function.
# New additions from the base script can be found quickly by
# looking for the # New Code # tags
#
# To run it in each of these various modes, follow the instructions
# in the readme for examples:
# https://github.com/huggingface/accelerate/tree/main/examples
#
########################################################################


lowercase   =	1_6
lowercase   =	3_2



def   __lowerCAmelCase    (				UpperCAmelCase__					:   Accelerator      ,					UpperCAmelCase__					:   DatasetDict      ,					UpperCAmelCase__					:   List[int]      ,					UpperCAmelCase__					:   List[int]      ,					UpperCAmelCase__					:   int = 1_6							)	->     List[str]:
							lowerCamelCase_					=       AutoTokenizer.from_pretrained("""bert-base-cased"""							)
							lowerCamelCase_					=       DatasetDict(
							    {
							        """train""": dataset["""train"""].select(UpperCAmelCase__							),
							        """validation""": dataset["""train"""].select(UpperCAmelCase__							),
							        """test""": dataset["""validation"""],
							    }							)

							def tokenize_function(UpperCAmelCase__					:   str							):
														# max_length=None => use the model max length (it's actually the default)
														lowerCamelCase_					=       tokenizer(examples["""sentence1"""]      ,					examples["""sentence2"""]      ,					truncation=UpperCAmelCase__      ,					max_length=UpperCAmelCase__							)
														return outputs

							# Apply the method we just defined to all the examples in all the splits of the dataset
							# starting with the main process first:
							with accelerator.main_process_first():
														lowerCamelCase_					=       datasets.map(
														    UpperCAmelCase__      ,					batched=UpperCAmelCase__      ,					remove_columns=["""idx""", """sentence1""", """sentence2"""]      ,					)

							# We also rename the 'label' column to 'labels' which is the expected name for labels by the models of the
							# transformers library
							lowerCamelCase_					=       tokenized_datasets.rename_column("""label"""      ,					"""labels"""							)

							def collate_fn(UpperCAmelCase__					:   Tuple							):
														# On TPU it's best to pad everything to the same length or training will be very slow.
														lowerCamelCase_					=       1_2_8 if accelerator.distributed_type == DistributedType.TPU else None
														# When using mixed precision we want round multiples of 8/16
														if accelerator.mixed_precision == "fp8":
																					lowerCamelCase_					=       1_6
														elif accelerator.mixed_precision != "no":
																					lowerCamelCase_					=       8
														else:
																					lowerCamelCase_					=       None

														return tokenizer.pad(
														    UpperCAmelCase__      ,					padding="""longest"""      ,					max_length=UpperCAmelCase__      ,					pad_to_multiple_of=UpperCAmelCase__      ,					return_tensors="""pt"""      ,					)

							# Instantiate dataloaders.
							lowerCamelCase_					=       DataLoader(
							    tokenized_datasets["""train"""]      ,					shuffle=UpperCAmelCase__      ,					collate_fn=UpperCAmelCase__      ,					batch_size=UpperCAmelCase__							)
							lowerCamelCase_					=       DataLoader(
							    tokenized_datasets["""validation"""]      ,					shuffle=UpperCAmelCase__      ,					collate_fn=UpperCAmelCase__      ,					batch_size=UpperCAmelCase__							)

							lowerCamelCase_					=       DataLoader(
							    tokenized_datasets["""test"""]      ,					shuffle=UpperCAmelCase__      ,					collate_fn=UpperCAmelCase__      ,					batch_size=UpperCAmelCase__							)

							return train_dataloader, eval_dataloader, test_dataloader



def   __lowerCAmelCase    (				UpperCAmelCase__					:   int      ,					UpperCAmelCase__					:   Optional[Any]							)	->     List[Any]:
							# New Code #
							lowerCamelCase_					=       []
							# Download the dataset
							lowerCamelCase_					=       load_dataset("""glue"""      ,					"""mrpc"""							)
							# Create our splits
							lowerCamelCase_					=       StratifiedKFold(n_splits=int(args.num_folds							)							)
							# Initialize accelerator
							lowerCamelCase_					=       Accelerator(cpu=args.cpu      ,					mixed_precision=args.mixed_precision							)
							# Sample hyper-parameters for learning rate, batch size, seed and a few other HPs
							lowerCamelCase_					=       config["""lr"""]
							lowerCamelCase_					=       int(config["""num_epochs"""]							)
							lowerCamelCase_					=       int(config["""seed"""]							)
							lowerCamelCase_					=       int(config["""batch_size"""]							)

							lowerCamelCase_					=       evaluate.load("""glue"""      ,					"""mrpc"""							)

							# If the batch size is too big we use gradient accumulation
							lowerCamelCase_					=       1
							if batch_size > MAX_GPU_BATCH_SIZE and accelerator.distributed_type != DistributedType.TPU:
														lowerCamelCase_					=       batch_size // MAX_GPU_BATCH_SIZE
														lowerCamelCase_					=       MAX_GPU_BATCH_SIZE

							set_seed(UpperCAmelCase__							)

							# New Code #
							# Create our folds:
							lowerCamelCase_					=       kfold.split(np.zeros(datasets["""train"""].num_rows							)      ,					datasets["""train"""]["""label"""]							)
							lowerCamelCase_					=       []
							# Iterate over them
							for i, (train_idxs, valid_idxs) in enumerate(UpperCAmelCase__							):
														lowerCamelCase_	, lowerCamelCase_	, lowerCamelCase_					=       get_fold_dataloaders(
														    UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__      ,					)
														# Instantiate the model (we build the model here so that the seed also control new weights initialization)
														lowerCamelCase_					=       AutoModelForSequenceClassification.from_pretrained("""bert-base-cased"""      ,					return_dict=UpperCAmelCase__							)

														# We could avoid this line since the accelerator is set with `device_placement=True` (default value).
														# Note that if you are placing tensors on devices manually, this line absolutely needs to be before the optimizer
														# creation otherwise training will not work on TPU (`accelerate` will kindly throw an error to make us aware of that).
														lowerCamelCase_					=       model.to(accelerator.device							)

														# Instantiate optimizer
														lowerCamelCase_					=       AdamW(params=model.parameters()      ,					lr=UpperCAmelCase__							)

														# Instantiate scheduler
														lowerCamelCase_					=       get_linear_schedule_with_warmup(
														    optimizer=UpperCAmelCase__      ,					num_warmup_steps=1_0_0      ,					num_training_steps=(len(UpperCAmelCase__							) * num_epochs) // gradient_accumulation_steps      ,					)

														# Prepare everything
														# There is no specific order to remember, we just need to unpack the objects in the same order we gave them to the
														# prepare method.
														lowerCamelCase_	, lowerCamelCase_	, lowerCamelCase_	, lowerCamelCase_	, lowerCamelCase_					=       accelerator.prepare(
														    UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__      ,					UpperCAmelCase__							)

														# Now we train the model
														for epoch in range(UpperCAmelCase__							):
																					model.train()
																					for step, batch in enumerate(UpperCAmelCase__							):
																												# We could avoid this line since we set the accelerator with `device_placement=True`.
																												batch.to(accelerator.device							)
																												lowerCamelCase_					=       model(**UpperCAmelCase__							)
																												lowerCamelCase_					=       outputs.loss
																												lowerCamelCase_					=       loss / gradient_accumulation_steps
																												accelerator.backward(UpperCAmelCase__							)
																												if step % gradient_accumulation_steps == 0:
																																			optimizer.step()
																																			lr_scheduler.step()
																																			optimizer.zero_grad()

																					model.eval()
																					for step, batch in enumerate(UpperCAmelCase__							):
																												# We could avoid this line since we set the accelerator with `device_placement=True`.
																												batch.to(accelerator.device							)
																												with torch.no_grad():
																																			lowerCamelCase_					=       model(**UpperCAmelCase__							)
																												lowerCamelCase_					=       outputs.logits.argmax(dim=-1							)
																												lowerCamelCase_	, lowerCamelCase_					=       accelerator.gather_for_metrics((predictions, batch["""labels"""])							)
																												metric.add_batch(
																												    predictions=UpperCAmelCase__      ,					references=UpperCAmelCase__      ,					)

																					lowerCamelCase_					=       metric.compute()
																					# Use accelerator.print to print only on the main process.
																					accelerator.print(F'''epoch {epoch}:'''      ,					UpperCAmelCase__							)

														# New Code #
														# We also run predictions on the test set at the very end
														lowerCamelCase_					=       []
														for step, batch in enumerate(UpperCAmelCase__							):
																					# We could avoid this line since we set the accelerator with `device_placement=True`.
																					batch.to(accelerator.device							)
																					with torch.no_grad():
																												lowerCamelCase_					=       model(**UpperCAmelCase__							)
																					lowerCamelCase_					=       outputs.logits
																					lowerCamelCase_	, lowerCamelCase_					=       accelerator.gather_for_metrics((predictions, batch["""labels"""])							)
																					fold_predictions.append(predictions.cpu()							)
																					if i == 0:
																												# We need all of the test predictions
																												test_references.append(references.cpu()							)
        # Use accelerator.print to print only on the main process.
														test_predictions.append(torch.cat(UpperCAmelCase__      ,					dim=0							)							)
														# We now need to release all our memory and get rid of the current model, optimizer, etc
														accelerator.free_memory()
							# New Code #
							# Finally we check the accuracy of our folded results:
							lowerCamelCase_					=       torch.cat(UpperCAmelCase__      ,					dim=0							)
							lowerCamelCase_					=       torch.stack(UpperCAmelCase__      ,					dim=0							).sum(dim=0							).div(int(args.num_folds							)							).argmax(dim=-1							)
							lowerCamelCase_					=       metric.compute(predictions=UpperCAmelCase__      ,					references=UpperCAmelCase__							)
							accelerator.print("""Average test metrics from all folds:"""      ,					UpperCAmelCase__							)



def   __lowerCAmelCase    (				)	->     int:
							lowerCamelCase_					=       argparse.ArgumentParser(description="""Simple example of training script."""							)
							parser.add_argument(
							    """--mixed_precision"""      ,					type=UpperCAmelCase__      ,					default=UpperCAmelCase__      ,					choices=["""no""", """fp16""", """bf16""", """fp8"""]      ,					help="""Whether to use mixed precision. Choose"""
							    """between fp16 and bf16 (bfloat16). Bf16 requires PyTorch >= 1.10."""
							    """and an Nvidia Ampere GPU."""      ,					)
							parser.add_argument("""--cpu"""      ,					action="""store_true"""      ,					help="""If passed, will train on the CPU."""							)
							# New Code #
							parser.add_argument("""--num_folds"""      ,					type=UpperCAmelCase__      ,					default=3      ,					help="""The number of splits to perform across the dataset"""							)
							lowerCamelCase_					=       parser.parse_args()
							lowerCamelCase_					=       {"""lr""": 2e-5, """num_epochs""": 3, """seed""": 4_2, """batch_size""": 1_6}
							training_function(UpperCAmelCase__      ,					UpperCAmelCase__							)


if __name__ == "__main__":
		main()







from __future__ import annotations

import unittest

from transformers import DebertaVaConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
		import tensorflow as tf

		from transformers import (
		    TFDebertaVaForMaskedLM,
		    TFDebertaVaForQuestionAnswering,
		    TFDebertaVaForSequenceClassification,
		    TFDebertaVaForTokenClassification,
		    TFDebertaVaModel,
		)





class    __A:

					def __init__(						self       :  List[Any] ,       __UpperCamelCase       :  Tuple ,       __UpperCamelCase       :  Any=1_3 ,       __UpperCamelCase       :  Optional[int]=7 ,       __UpperCamelCase       :  Any=True ,       __UpperCamelCase       :  Dict=True ,       __UpperCamelCase       :  Optional[Any]=True ,       __UpperCamelCase       :  Dict=True ,       __UpperCamelCase       :  Union[str, Any]=9_9 ,       __UpperCamelCase       :  List[str]=3_2 ,       __UpperCamelCase       :  int=2 ,       __UpperCamelCase       :  Optional[Any]=4 ,       __UpperCamelCase       :  Optional[int]=3_7 ,       __UpperCamelCase       :  Optional[Any]="gelu" ,       __UpperCamelCase       :  int=0.1 ,       __UpperCamelCase       :  str=0.1 ,       __UpperCamelCase       :  Tuple=5_1_2 ,       __UpperCamelCase       :  Any=1_6 ,       __UpperCamelCase       :  Dict=2 ,       __UpperCamelCase       :  Optional[Any]=0.02 ,       __UpperCamelCase       :  Optional[Any]=False ,       __UpperCamelCase       :  Dict=True ,       __UpperCamelCase       :  Any="None" ,       __UpperCamelCase       :  List[Any]=3 ,       __UpperCamelCase       :  Optional[int]=4 ,       __UpperCamelCase       :  Dict=None ,       ):
												lowerCamelCase_					=       parent
												lowerCamelCase_					=       batch_size
												lowerCamelCase_					=       seq_length
												lowerCamelCase_					=       is_training
												lowerCamelCase_					=       use_input_mask
												lowerCamelCase_					=       use_token_type_ids
												lowerCamelCase_					=       use_labels
												lowerCamelCase_					=       vocab_size
												lowerCamelCase_					=       hidden_size
												lowerCamelCase_					=       num_hidden_layers
												lowerCamelCase_					=       num_attention_heads
												lowerCamelCase_					=       intermediate_size
												lowerCamelCase_					=       hidden_act
												lowerCamelCase_					=       hidden_dropout_prob
												lowerCamelCase_					=       attention_probs_dropout_prob
												lowerCamelCase_					=       max_position_embeddings
												lowerCamelCase_					=       type_vocab_size
												lowerCamelCase_					=       type_sequence_label_size
												lowerCamelCase_					=       initializer_range
												lowerCamelCase_					=       num_labels
												lowerCamelCase_					=       num_choices
												lowerCamelCase_					=       relative_attention
												lowerCamelCase_					=       position_biased_input
												lowerCamelCase_					=       pos_att_type
												lowerCamelCase_					=       scope

					def  lowercase__   (						self       :  Optional[Any] ):
												lowerCamelCase_					=       ids_tensor([self.batch_size, self.seq_length] ,       self.vocab_size )

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

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

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

												lowerCamelCase_					=       DebertaVaConfig(
												    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 ,       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 ,       relative_attention=self.relative_attention ,       position_biased_input=self.position_biased_input ,       initializer_range=self.initializer_range ,       return_dict=__UpperCamelCase ,       )

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

					def  lowercase__   (						self       :  str ,       __UpperCamelCase       :  Union[str, Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  Any ,       __UpperCamelCase       :  int ,       __UpperCamelCase       :  List[str] ):
												lowerCamelCase_					=       TFDebertaVaModel(config=__UpperCamelCase )
												lowerCamelCase_					=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

												lowerCamelCase_					=       [input_ids, input_mask]
												lowerCamelCase_					=       model(__UpperCamelCase )

												lowerCamelCase_					=       model(__UpperCamelCase )

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

					def  lowercase__   (						self       :  Optional[int] ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Dict ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  Tuple ,       __UpperCamelCase       :  int ):
												lowerCamelCase_					=       TFDebertaVaForMaskedLM(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}
												lowerCamelCase_					=       model(__UpperCamelCase )
												self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.seq_length, self.vocab_size) )

					def  lowercase__   (						self       :  List[Any] ,       __UpperCamelCase       :  Union[str, Any] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  int ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  List[Any] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  List[Any] ):
												lowerCamelCase_					=       self.num_labels
												lowerCamelCase_					=       TFDebertaVaForSequenceClassification(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}

												lowerCamelCase_					=       model(__UpperCamelCase )
												self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.num_labels) )

					def  lowercase__   (						self       :  int ,       __UpperCamelCase       :  Tuple ,       __UpperCamelCase       :  Any ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  List[Any] ,       __UpperCamelCase       :  List[Any] ):
												lowerCamelCase_					=       self.num_labels
												lowerCamelCase_					=       TFDebertaVaForTokenClassification(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}
												lowerCamelCase_					=       model(__UpperCamelCase )
												self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.seq_length, self.num_labels) )

					def  lowercase__   (						self       :  List[Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  int ):
												lowerCamelCase_					=       TFDebertaVaForQuestionAnswering(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}

												lowerCamelCase_					=       model(__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  lowercase__   (						self       :  Dict ):
												lowerCamelCase_					=       self.prepare_config_and_inputs()
												(
												    (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, 
												)					=       config_and_inputs
												lowerCamelCase_					=       {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
												return config, inputs_dict





@require_tf
class    __A(					UpperCAmelCase  ,		UpperCAmelCase  ,		unittest.TestCase							):
					SCREAMING_SNAKE_CASE           =     (
					    (
					        TFDebertaVaModel,
					        TFDebertaVaForMaskedLM,
					        TFDebertaVaForQuestionAnswering,
					        TFDebertaVaForSequenceClassification,
					        TFDebertaVaForTokenClassification,
					    )
					    if is_tf_available()
					    else ()
					)
					SCREAMING_SNAKE_CASE           =     (
					    {
					        '''feature-extraction''': TFDebertaVaModel,
					        '''fill-mask''': TFDebertaVaForMaskedLM,
					        '''question-answering''': TFDebertaVaForQuestionAnswering,
					        '''text-classification''': TFDebertaVaForSequenceClassification,
					        '''token-classification''': TFDebertaVaForTokenClassification,
					        '''zero-shot''': TFDebertaVaForSequenceClassification,
					    }
					    if is_tf_available()
					    else {}
					)

					SCREAMING_SNAKE_CASE           =     False
					SCREAMING_SNAKE_CASE           =     False

					def  lowercase__   (						self       :  Dict ):
												lowerCamelCase_					=       TFDebertaVaModelTester(self )
												lowerCamelCase_					=       ConfigTester(self ,       config_class=__UpperCamelCase ,       hidden_size=3_7 )

					def  lowercase__   (						self       :  Dict ):
												self.config_tester.run_common_tests()

					def  lowercase__   (						self       :  Optional[Any] ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*__UpperCamelCase )

					def  lowercase__   (						self       :  Dict ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_masked_lm(*__UpperCamelCase )

					def  lowercase__   (						self       :  List[Any] ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_question_answering(*__UpperCamelCase )

					def  lowercase__   (						self       :  Tuple ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_sequence_classification(*__UpperCamelCase )

					def  lowercase__   (						self       :  Any ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_token_classification(*__UpperCamelCase )



					@slow
					def  lowercase__   (						self       :  int ):
												lowerCamelCase_					=       TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge""" )
												self.assertIsNotNone(__UpperCamelCase )





@require_tf
class    __A(					unittest.TestCase							):

					@unittest.skip(reason="""Model not available yet""" )
					def  lowercase__   (						self       :  Optional[int] ):
												pass



					@slow
					def  lowercase__   (						self       :  Any ):
												lowerCamelCase_					=       TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge""" )
												lowerCamelCase_					=       tf.constant([[0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9, 4_6_0_7_8, 1_5_8_8, 2]] )
												lowerCamelCase_					=       tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] )
												lowerCamelCase_					=       model(__UpperCamelCase ,       attention_mask=__UpperCamelCase )[0]

												lowerCamelCase_					=       tf.constant(
												    [[[0.2356, 0.1948, 0.0369], [-0.1063, 0.3586, -0.5152], [-0.6399, -0.0259, -0.2525]]] )
												tf.debugging.assert_near(output[:, 1:4, 1:4] ,       __UpperCamelCase ,       atol=1E-4 )





