
"""simple docstring"""


from __future__ import annotations

import unittest

from transformers import MobileBertConfig, is_tf_available
from transformers.models.auto import get_values
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 (
          TF_MODEL_FOR_PRETRAINING_MAPPING,
          TFMobileBertForMaskedLM,
          TFMobileBertForMultipleChoice,
          TFMobileBertForNextSentencePrediction,
          TFMobileBertForPreTraining,
          TFMobileBertForQuestionAnswering,
          TFMobileBertForSequenceClassification,
          TFMobileBertForTokenClassification,
          TFMobileBertModel,
      )



@require_tf
class 	__a	(   _lowerCAmelCase     ,  _lowerCAmelCase     ,  unittest.TestCase						):
       UpperCamelCase_		:       str				=      (
           (
               TFMobileBertModel,
               TFMobileBertForMaskedLM,
               TFMobileBertForNextSentencePrediction,
               TFMobileBertForPreTraining,
               TFMobileBertForQuestionAnswering,
               TFMobileBertForSequenceClassification,
               TFMobileBertForTokenClassification,
               TFMobileBertForMultipleChoice,
           )
           if is_tf_available()
           else ()
       )
       UpperCamelCase_		:       str				=      (
           {
               '''feature-extraction''': TFMobileBertModel,
               '''fill-mask''': TFMobileBertForMaskedLM,
               '''question-answering''': TFMobileBertForQuestionAnswering,
               '''text-classification''': TFMobileBertForSequenceClassification,
               '''token-classification''': TFMobileBertForTokenClassification,
               '''zero-shot''': TFMobileBertForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )
       UpperCamelCase_		:       Optional[int]				=      False
       UpperCamelCase_		:       List[str]				=      False






       def 						_SCREAMING_SNAKE_CASE							(	self			:				List[str]							,   UpperCAmelCase_			:				Union[str, Any]							,   UpperCAmelCase_			:				Optional[Any]							,   UpperCAmelCase_			:				Union[str, Any]=False      )->	List[str]:







              """simple docstring"""
              UpperCamelCase       			=		super()._prepare_for_class(UpperCAmelCase_							,   UpperCAmelCase_							,   return_labels=UpperCAmelCase_      )

              if return_labels:
                     if model_class in get_values(UpperCAmelCase_      ):
                            UpperCamelCase       			=		tf.zeros(self.model_tester.batch_size							,   dtype=tf.intaa      )

              return inputs_dict



       class 	__a	(   _lowerCAmelCase						):






              def __init__(	self			:				Dict							,   UpperCAmelCase_			:				Optional[int]							,   UpperCAmelCase_			:				str=13							,   UpperCAmelCase_			:				Dict=7							,   UpperCAmelCase_			:				List[str]=True							,   UpperCAmelCase_			:				Union[str, Any]=True							,   UpperCAmelCase_			:				Any=True							,   UpperCAmelCase_			:				List[Any]=True							,   UpperCAmelCase_			:				Optional[int]=99							,   UpperCAmelCase_			:				Optional[int]=32							,   UpperCAmelCase_			:				Union[str, Any]=32							,   UpperCAmelCase_			:				Any=2							,   UpperCAmelCase_			:				Tuple=4							,   UpperCAmelCase_			:				Dict=37							,   UpperCAmelCase_			:				List[Any]="gelu"							,   UpperCAmelCase_			:				List[str]=0.1							,   UpperCAmelCase_			:				Any=0.1							,   UpperCAmelCase_			:				Any=512							,   UpperCAmelCase_			:				str=16							,   UpperCAmelCase_			:				int=2							,   UpperCAmelCase_			:				Tuple=0.02							,   UpperCAmelCase_			:				Dict=3							,   UpperCAmelCase_			:				Tuple=4							,   UpperCAmelCase_			:				Optional[int]=None							,   )->	str:







                     """simple docstring"""
                     UpperCamelCase       			=		parent
                     UpperCamelCase       			=		batch_size
                     UpperCamelCase       			=		seq_length
                     UpperCamelCase       			=		is_training
                     UpperCamelCase       			=		use_input_mask
                     UpperCamelCase       			=		use_token_type_ids
                     UpperCamelCase       			=		use_labels
                     UpperCamelCase       			=		vocab_size
                     UpperCamelCase       			=		hidden_size
                     UpperCamelCase       			=		num_hidden_layers
                     UpperCamelCase       			=		num_attention_heads
                     UpperCamelCase       			=		intermediate_size
                     UpperCamelCase       			=		hidden_act
                     UpperCamelCase       			=		hidden_dropout_prob
                     UpperCamelCase       			=		attention_probs_dropout_prob
                     UpperCamelCase       			=		max_position_embeddings
                     UpperCamelCase       			=		type_vocab_size
                     UpperCamelCase       			=		type_sequence_label_size
                     UpperCamelCase       			=		initializer_range
                     UpperCamelCase       			=		num_labels
                     UpperCamelCase       			=		num_choices
                     UpperCamelCase       			=		scope
                     UpperCamelCase       			=		embedding_size






              def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[int]      )->	Union[str, Any]:







                     """simple docstring"""
                     UpperCamelCase       			=		ids_tensor([self.batch_size, self.seq_length]							,   self.vocab_size      )

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

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

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

                     UpperCamelCase       			=		MobileBertConfig(
                         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							,   initializer_range=self.initializer_range							,   embedding_size=self.embedding_size							,   )

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






              def 						_SCREAMING_SNAKE_CASE							(	self			:				Tuple							,   UpperCAmelCase_			:				Optional[int]							,   UpperCAmelCase_			:				List[str]							,   UpperCAmelCase_			:				Any							,   UpperCAmelCase_			:				Any							,   UpperCAmelCase_			:				Union[str, Any]							,   UpperCAmelCase_			:				Dict							,   UpperCAmelCase_			:				Union[str, Any]      )->	int:







                     """simple docstring"""
                     UpperCamelCase       			=		TFMobileBertModel(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		model(UpperCAmelCase_      )

                     UpperCamelCase       			=		[input_ids, input_mask]
                     UpperCamelCase       			=		model(UpperCAmelCase_      )

                     UpperCamelCase       			=		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 						_SCREAMING_SNAKE_CASE							(	self			:				Any							,   UpperCAmelCase_			:				str							,   UpperCAmelCase_			:				int							,   UpperCAmelCase_			:				List[str]							,   UpperCAmelCase_			:				int							,   UpperCAmelCase_			:				Optional[int]							,   UpperCAmelCase_			:				Optional[Any]							,   UpperCAmelCase_			:				int      )->	Any:







                     """simple docstring"""
                     UpperCamelCase       			=		TFMobileBertForMaskedLM(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		model(UpperCAmelCase_      )
                     self.parent.assertEqual(result.logits.shape							,   (self.batch_size, self.seq_length, self.vocab_size)      )






              def 						_SCREAMING_SNAKE_CASE							(	self			:				Dict							,   UpperCAmelCase_			:				List[Any]							,   UpperCAmelCase_			:				Optional[Any]							,   UpperCAmelCase_			:				Optional[Any]							,   UpperCAmelCase_			:				str							,   UpperCAmelCase_			:				int							,   UpperCAmelCase_			:				Union[str, Any]							,   UpperCAmelCase_			:				Union[str, Any]      )->	List[str]:







                     """simple docstring"""
                     UpperCamelCase       			=		TFMobileBertForNextSentencePrediction(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		model(UpperCAmelCase_      )
                     self.parent.assertEqual(result.logits.shape							,   (self.batch_size, 2)      )






              def 						_SCREAMING_SNAKE_CASE							(	self			:				Tuple							,   UpperCAmelCase_			:				Union[str, Any]							,   UpperCAmelCase_			:				Dict							,   UpperCAmelCase_			:				Optional[int]							,   UpperCAmelCase_			:				List[Any]							,   UpperCAmelCase_			:				Tuple							,   UpperCAmelCase_			:				Tuple							,   UpperCAmelCase_			:				List[Any]      )->	str:







                     """simple docstring"""
                     UpperCamelCase       			=		TFMobileBertForPreTraining(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		model(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 						_SCREAMING_SNAKE_CASE							(	self			:				Union[str, Any]							,   UpperCAmelCase_			:				Tuple							,   UpperCAmelCase_			:				List[str]							,   UpperCAmelCase_			:				List[str]							,   UpperCAmelCase_			:				Optional[Any]							,   UpperCAmelCase_			:				Dict							,   UpperCAmelCase_			:				str							,   UpperCAmelCase_			:				str      )->	Any:







                     """simple docstring"""
                     UpperCamelCase       			=		self.num_labels
                     UpperCamelCase       			=		TFMobileBertForSequenceClassification(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		model(UpperCAmelCase_      )
                     self.parent.assertEqual(result.logits.shape							,   (self.batch_size, self.num_labels)      )






              def 						_SCREAMING_SNAKE_CASE							(	self			:				int							,   UpperCAmelCase_			:				Union[str, Any]							,   UpperCAmelCase_			:				List[Any]							,   UpperCAmelCase_			:				Tuple							,   UpperCAmelCase_			:				Any							,   UpperCAmelCase_			:				Optional[int]							,   UpperCAmelCase_			:				Union[str, Any]							,   UpperCAmelCase_			:				List[Any]      )->	Dict:







                     """simple docstring"""
                     UpperCamelCase       			=		self.num_choices
                     UpperCamelCase       			=		TFMobileBertForMultipleChoice(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		tf.tile(tf.expand_dims(UpperCAmelCase_							,   1      )							,   (1, self.num_choices, 1)      )
                     UpperCamelCase       			=		tf.tile(tf.expand_dims(UpperCAmelCase_							,   1      )							,   (1, self.num_choices, 1)      )
                     UpperCamelCase       			=		tf.tile(tf.expand_dims(UpperCAmelCase_							,   1      )							,   (1, self.num_choices, 1)      )
                     UpperCamelCase       			=		{
                         "input_ids": multiple_choice_inputs_ids,
                         "attention_mask": multiple_choice_input_mask,
                         "token_type_ids": multiple_choice_token_type_ids,
                     }
                     UpperCamelCase       			=		model(UpperCAmelCase_      )
                     self.parent.assertEqual(result.logits.shape							,   (self.batch_size, self.num_choices)      )






              def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]							,   UpperCAmelCase_			:				List[Any]							,   UpperCAmelCase_			:				Tuple							,   UpperCAmelCase_			:				Optional[Any]							,   UpperCAmelCase_			:				str							,   UpperCAmelCase_			:				Any							,   UpperCAmelCase_			:				int							,   UpperCAmelCase_			:				Optional[Any]      )->	Union[str, Any]:







                     """simple docstring"""
                     UpperCamelCase       			=		self.num_labels
                     UpperCamelCase       			=		TFMobileBertForTokenClassification(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		model(UpperCAmelCase_      )
                     self.parent.assertEqual(result.logits.shape							,   (self.batch_size, self.seq_length, self.num_labels)      )






              def 						_SCREAMING_SNAKE_CASE							(	self			:				Union[str, Any]							,   UpperCAmelCase_			:				int							,   UpperCAmelCase_			:				List[Any]							,   UpperCAmelCase_			:				Tuple							,   UpperCAmelCase_			:				str							,   UpperCAmelCase_			:				Any							,   UpperCAmelCase_			:				int							,   UpperCAmelCase_			:				int      )->	int:







                     """simple docstring"""
                     UpperCamelCase       			=		TFMobileBertForQuestionAnswering(config=UpperCAmelCase_      )
                     UpperCamelCase       			=		{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
                     UpperCamelCase       			=		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 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[int]      )->	Optional[int]:







                     """simple docstring"""
                     UpperCamelCase       			=		self.prepare_config_and_inputs()
                     (
                         (
                         UpperCamelCase
                     )			,							(
                         UpperCamelCase
                     )			,							(
                         UpperCamelCase
                     )			,							(
                         UpperCamelCase
                     )			,							(
                         UpperCamelCase
                     )			,							(
                         UpperCamelCase
                     )			,							(
                         UpperCamelCase
                     )			,							
                     )       			=		config_and_inputs
                     UpperCamelCase       			=		{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
                     return config, inputs_dict






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Any      )->	Optional[int]:







              """simple docstring"""
              UpperCamelCase       			=		TFMobileBertModelTest.TFMobileBertModelTester(self      )
              UpperCamelCase       			=		ConfigTester(self							,   config_class=UpperCAmelCase_							,   hidden_size=37      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Dict      )->	Tuple:







              """simple docstring"""
              self.config_tester.run_common_tests()






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Dict      )->	Optional[Any]:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_model(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[int]      )->	Optional[int]:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_masked_lm(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Tuple      )->	Dict:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_multiple_choice(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]      )->	Optional[Any]:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_next_sequence_prediction(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				int      )->	Tuple:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_pretraining(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]      )->	Tuple:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_question_answering(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]      )->	Union[str, Any]:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_sequence_classification(*UpperCAmelCase_      )






       def 						_SCREAMING_SNAKE_CASE							(	self			:				Tuple      )->	Any:







              """simple docstring"""
              UpperCamelCase       			=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_mobilebert_for_token_classification(*UpperCAmelCase_      )






       @slow
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]      )->	Optional[Any]:







              """simple docstring"""
              # for model_name in TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              for model_name in ["google/mobilebert-uncased"]:
                     UpperCamelCase       			=		TFMobileBertModel.from_pretrained(UpperCAmelCase_      )
                     self.assertIsNotNone(UpperCAmelCase_      )





@require_tf
class 	__a	(   unittest.TestCase						):






       @slow
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Tuple      )->	Tuple:







              """simple docstring"""
              UpperCamelCase       			=		TFMobileBertForPreTraining.from_pretrained("google/mobilebert-uncased"      )
              UpperCamelCase       			=		tf.constant([[0, 1, 2, 3, 4, 5]]      )
              UpperCamelCase       			=		model(UpperCAmelCase_      )[0]

              UpperCamelCase       			=		[1, 6, 30_522]
              self.assertEqual(output.shape							,   UpperCAmelCase_      )

              UpperCamelCase       			=		tf.constant(
                  [
                      [
                          [-4.5919547, -9.248295, -9.645256],
                          [-6.7306175, -6.440284, -6.6052837],
                          [-7.2743506, -6.7847915, -6.024673],
                      ]
                  ]      )
              tf.debugging.assert_near(output[:, :3, :3]							,   UpperCAmelCase_							,   atol=1e-4      )







"""simple docstring"""


from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments
from transformers.testing_utils import TestCasePlus, require_torch, slow
from transformers.utils import is_datasets_available


if is_datasets_available():
      import datasets



class 	__a	(   _lowerCAmelCase						):






       @slow
       @require_torch
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[int]      )->	Dict:







              """simple docstring"""
              UpperCamelCase       			=		EncoderDecoderModel.from_encoder_decoder_pretrained("prajjwal1/bert-tiny"							,   "prajjwal1/bert-tiny"      )
              UpperCamelCase       			=		BertTokenizer.from_pretrained("bert-base-uncased"      )

              UpperCamelCase       			=		bertabert.config.encoder.vocab_size
              UpperCamelCase       			=		tokenizer.sep_token_id
              UpperCamelCase       			=		tokenizer.cls_token_id
              UpperCamelCase       			=		128

              UpperCamelCase       			=		datasets.load_dataset("cnn_dailymail"							,   "3.0.0"							,   split="train[:1%]"      )
              UpperCamelCase       			=		datasets.load_dataset("cnn_dailymail"							,   "3.0.0"							,   split="validation[:1%]"      )

              UpperCamelCase       			=		train_dataset.select(range(32      )      )
              UpperCamelCase       			=		val_dataset.select(range(16      )      )

              UpperCamelCase       			=		4

              def _map_to_encoder_decoder_inputs(UpperCAmelCase_			:				Any      ):
                     # Tokenizer will automatically set [BOS] <text> [EOS]
                     UpperCamelCase       			=		tokenizer(batch["article"]							,   padding="max_length"							,   truncation=UpperCAmelCase_							,   max_length=512      )
                     UpperCamelCase       			=		tokenizer(batch["highlights"]							,   padding="max_length"							,   truncation=UpperCAmelCase_							,   max_length=128      )
                     UpperCamelCase       			=		inputs.input_ids
                     UpperCamelCase       			=		inputs.attention_mask

                     UpperCamelCase       			=		outputs.input_ids
                     UpperCamelCase       			=		outputs.input_ids.copy()
                     UpperCamelCase       			=		[
                         [-100 if token == tokenizer.pad_token_id else token for token in labels] for labels in batch["labels"]
                     ]
                     UpperCamelCase       			=		outputs.attention_mask

                     assert all(len(UpperCAmelCase_      ) == 512 for x in inputs.input_ids      )
                     assert all(len(UpperCAmelCase_      ) == 128 for x in outputs.input_ids      )

                     return batch

              def _compute_metrics(UpperCAmelCase_			:				Any      ):
                     UpperCamelCase       			=		pred.label_ids
                     UpperCamelCase       			=		pred.predictions

                     # all unnecessary tokens are removed
                     UpperCamelCase       			=		tokenizer.batch_decode(UpperCAmelCase_							,   skip_special_tokens=UpperCAmelCase_      )
                     UpperCamelCase       			=		tokenizer.batch_decode(UpperCAmelCase_							,   skip_special_tokens=UpperCAmelCase_      )

                     UpperCamelCase       			=		sum([int(pred_str[i] == label_str[i]      ) for i in range(len(UpperCAmelCase_      )      )]      ) / len(UpperCAmelCase_      )

                     return {"accuracy": accuracy}

              # map train dataset
              UpperCamelCase       			=		train_dataset.map(
                  _map_to_encoder_decoder_inputs							,   batched=UpperCAmelCase_							,   batch_size=UpperCAmelCase_							,   remove_columns=["article", "highlights"]							,   )
              train_dataset.set_format(
                  type="torch"							,   columns=["input_ids", "attention_mask", "decoder_input_ids", "decoder_attention_mask", "labels"]							,   )

              # same for validation dataset
              UpperCamelCase       			=		val_dataset.map(
                  _map_to_encoder_decoder_inputs							,   batched=UpperCAmelCase_							,   batch_size=UpperCAmelCase_							,   remove_columns=["article", "highlights"]							,   )
              val_dataset.set_format(
                  type="torch"							,   columns=["input_ids", "attention_mask", "decoder_input_ids", "decoder_attention_mask", "labels"]							,   )

              UpperCamelCase       			=		self.get_auto_remove_tmp_dir()

              UpperCamelCase       			=		SeqaSeqTrainingArguments(
                  output_dir=UpperCAmelCase_							,   per_device_train_batch_size=UpperCAmelCase_							,   per_device_eval_batch_size=UpperCAmelCase_							,   predict_with_generate=UpperCAmelCase_							,   evaluation_strategy="steps"							,   do_train=UpperCAmelCase_							,   do_eval=UpperCAmelCase_							,   warmup_steps=0							,   eval_steps=2							,   logging_steps=2							,   )

              # instantiate trainer
              UpperCamelCase       			=		SeqaSeqTrainer(
                  model=UpperCAmelCase_							,   args=UpperCAmelCase_							,   compute_metrics=_compute_metrics							,   train_dataset=UpperCAmelCase_							,   eval_dataset=UpperCAmelCase_							,   tokenizer=UpperCAmelCase_							,   )

              # start training
              trainer.train()





