


import os
import tempfile
import unittest

from transformers import NezhaConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch

   from transformers import (
       MODEL_FOR_PRETRAINING_MAPPING,
       NezhaForMaskedLM,
       NezhaForMultipleChoice,
       NezhaForNextSentencePrediction,
       NezhaForPreTraining,
       NezhaForQuestionAnswering,
       NezhaForSequenceClassification,
       NezhaForTokenClassification,
       NezhaModel,
   )
   from transformers.models.nezha.modeling_nezha import NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST
class 				SCREAMING_SNAKE_CASE__						:
      def __init__( self       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : List[str]=1_3  ,							SCREAMING_SNAKE_CASE__       : Dict=7  ,							SCREAMING_SNAKE_CASE__       : Optional[int]=True  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]=True  ,							SCREAMING_SNAKE_CASE__       : str=True  ,							SCREAMING_SNAKE_CASE__       : List[Any]=True  ,							SCREAMING_SNAKE_CASE__       : List[Any]=9_9  ,							SCREAMING_SNAKE_CASE__       : List[str]=3_2  ,							SCREAMING_SNAKE_CASE__       : List[str]=5  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]=4  ,							SCREAMING_SNAKE_CASE__       : List[Any]=3_7  ,							SCREAMING_SNAKE_CASE__       : int="gelu"  ,							SCREAMING_SNAKE_CASE__       : Any=0.1  ,							SCREAMING_SNAKE_CASE__       : Tuple=0.1  ,							SCREAMING_SNAKE_CASE__       : Optional[int]=1_2_8  ,							SCREAMING_SNAKE_CASE__       : Optional[int]=3_2  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]=1_6  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]=2  ,							SCREAMING_SNAKE_CASE__       : Dict=0.02  ,							SCREAMING_SNAKE_CASE__       : int=3  ,							SCREAMING_SNAKE_CASE__       : Tuple=4  ,							SCREAMING_SNAKE_CASE__       : Any=None  ,							)	->    Optional[Any]:
             a_      :	Dict							=						parent
             a_      :	List[Any]							=						batch_size
             a_      :	str							=						seq_length
             a_      :	Optional[Any]							=						is_training
             a_      :	Any							=						use_input_mask
             a_      :	Union[str, Any]							=						use_token_type_ids
             a_      :	Union[str, Any]							=						use_labels
             a_      :	Tuple							=						vocab_size
             a_      :	List[Any]							=						hidden_size
             a_      :	Dict							=						num_hidden_layers
             a_      :	str							=						num_attention_heads
             a_      :	Tuple							=						intermediate_size
             a_      :	Dict							=						hidden_act
             a_      :	str							=						hidden_dropout_prob
             a_      :	Dict							=						attention_probs_dropout_prob
             a_      :	Dict							=						max_position_embeddings
             a_      :	int							=						type_vocab_size
             a_      :	Any							=						type_sequence_label_size
             a_      :	Dict							=						initializer_range
             a_      :	Any							=						num_labels
             a_      :	str							=						num_choices
             a_      :	List[Any]							=						scope
      def  SCREAMING_SNAKE_CASE							( self       : Optional[Any]  )	->    int:
             a_      :	Optional[Any]							=						ids_tensor([self.batch_size, self.seq_length]  ,							self.vocab_size  )

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

             a_      :	int							=						None
             if self.use_token_type_ids:
                    a_      :	Optional[Any]							=						ids_tensor([self.batch_size, self.seq_length]  ,							self.type_vocab_size  )

             a_      :	Union[str, Any]							=						None
             a_      :	Any							=						None
             a_      :	Optional[int]							=						None
             if self.use_labels:
                    a_      :	Dict							=						ids_tensor([self.batch_size]  ,							self.type_sequence_label_size  )
                    a_      :	List[str]							=						ids_tensor([self.batch_size, self.seq_length]  ,							self.num_labels  )
                    a_      :	Any							=						ids_tensor([self.batch_size]  ,							self.num_choices  )

             a_      :	List[str]							=						self.get_config()

             return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
      def  SCREAMING_SNAKE_CASE							( self       : Dict  )	->    str:
             return NezhaConfig(
                 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  ,							is_decoder=SCREAMING_SNAKE_CASE__  ,							initializer_range=self.initializer_range  ,							)
      def  SCREAMING_SNAKE_CASE							( self       : Dict  )	->    List[Any]:
             (
                 (
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	
             )      :	str							=						self.prepare_config_and_inputs()

             a_      :	List[Any]							=						True
             a_      :	List[Any]							=						floats_tensor([self.batch_size, self.seq_length, self.hidden_size]  )
             a_      :	Tuple							=						ids_tensor([self.batch_size, self.seq_length]  ,							vocab_size=2  )

             return (
                 config,
                 input_ids,
                 token_type_ids,
                 input_mask,
                 sequence_labels,
                 token_labels,
                 choice_labels,
                 encoder_hidden_states,
                 encoder_attention_mask,
             )
      def  SCREAMING_SNAKE_CASE							( self       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : int  )	->    List[str]:
             a_      :	Dict							=						NezhaModel(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	Union[str, Any]							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  )
             a_      :	str							=						model(SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  )
             a_      :	int							=						model(SCREAMING_SNAKE_CASE__  )
             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  ,							SCREAMING_SNAKE_CASE__       : List[str]  ,							SCREAMING_SNAKE_CASE__       : List[str]  ,							SCREAMING_SNAKE_CASE__       : Dict  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : str  ,							SCREAMING_SNAKE_CASE__       : Dict  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							)	->    Optional[Any]:
             a_      :	Optional[int]							=						True
             a_      :	Optional[Any]							=						NezhaModel(SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	int							=						model(
                 SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							encoder_hidden_states=SCREAMING_SNAKE_CASE__  ,							encoder_attention_mask=SCREAMING_SNAKE_CASE__  ,							)
             a_      :	Tuple							=						model(
                 SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							encoder_hidden_states=SCREAMING_SNAKE_CASE__  ,							)
             a_      :	Dict							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  )
             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       : int  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : Any  )	->    List[str]:
             a_      :	List[str]							=						NezhaForMaskedLM(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	Dict							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							labels=SCREAMING_SNAKE_CASE__  )
             self.parent.assertEqual(result.logits.shape  ,							(self.batch_size, self.seq_length, self.vocab_size)  )
      def  SCREAMING_SNAKE_CASE							( self       : List[str]  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : List[str]  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Tuple  )	->    int:
             a_      :	Optional[int]							=						NezhaForNextSentencePrediction(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	List[str]							=						model(
                 SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							labels=SCREAMING_SNAKE_CASE__  ,							)
             self.parent.assertEqual(result.logits.shape  ,							(self.batch_size, 2)  )
      def  SCREAMING_SNAKE_CASE							( self       : List[Any]  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Optional[int]  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : List[Any]  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  )	->    Any:
             a_      :	Any							=						NezhaForPreTraining(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	Any							=						model(
                 SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							labels=SCREAMING_SNAKE_CASE__  ,							next_sentence_label=SCREAMING_SNAKE_CASE__  ,							)
             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       : Optional[int]  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Optional[int]  ,							SCREAMING_SNAKE_CASE__       : Dict  )	->    Any:
             a_      :	int							=						NezhaForQuestionAnswering(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	Dict							=						model(
                 SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							start_positions=SCREAMING_SNAKE_CASE__  ,							end_positions=SCREAMING_SNAKE_CASE__  ,							)
             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       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : str  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  )	->    Tuple:
             a_      :	Optional[Any]							=						self.num_labels
             a_      :	Any							=						NezhaForSequenceClassification(SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	List[Any]							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							labels=SCREAMING_SNAKE_CASE__  )
             self.parent.assertEqual(result.logits.shape  ,							(self.batch_size, self.num_labels)  )
      def  SCREAMING_SNAKE_CASE							( self       : Optional[int]  ,							SCREAMING_SNAKE_CASE__       : List[Any]  ,							SCREAMING_SNAKE_CASE__       : List[str]  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : Tuple  )	->    Any:
             a_      :	Any							=						self.num_labels
             a_      :	List[str]							=						NezhaForTokenClassification(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	int							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							labels=SCREAMING_SNAKE_CASE__  )
             self.parent.assertEqual(result.logits.shape  ,							(self.batch_size, self.seq_length, self.num_labels)  )
      def  SCREAMING_SNAKE_CASE							( self       : int  ,							SCREAMING_SNAKE_CASE__       : Dict  ,							SCREAMING_SNAKE_CASE__       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : List[Any]  ,							SCREAMING_SNAKE_CASE__       : Any  ,							SCREAMING_SNAKE_CASE__       : Tuple  ,							SCREAMING_SNAKE_CASE__       : str  )	->    str:
             a_      :	List[Any]							=						self.num_choices
             a_      :	List[Any]							=						NezhaForMultipleChoice(config=SCREAMING_SNAKE_CASE__  )
             model.to(SCREAMING_SNAKE_CASE__  )
             model.eval()
             a_      :	List[Any]							=						input_ids.unsqueeze(1  ).expand(-1  ,							self.num_choices  ,							-1  ).contiguous()
             a_      :	str							=						token_type_ids.unsqueeze(1  ).expand(-1  ,							self.num_choices  ,							-1  ).contiguous()
             a_      :	Dict							=						input_mask.unsqueeze(1  ).expand(-1  ,							self.num_choices  ,							-1  ).contiguous()
             a_      :	Union[str, Any]							=						model(
                 SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  ,							token_type_ids=SCREAMING_SNAKE_CASE__  ,							labels=SCREAMING_SNAKE_CASE__  ,							)
             self.parent.assertEqual(result.logits.shape  ,							(self.batch_size, self.num_choices)  )

      def  SCREAMING_SNAKE_CASE							( self       : List[Any]  )	->    str:
             a_      :	Optional[Any]							=						self.prepare_config_and_inputs()
             (
                 (
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	
             )      :	str							=						config_and_inputs
             a_      :	int							=						{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
             return config, inputs_dict
@require_torch
class 				SCREAMING_SNAKE_CASE__						(       lowercase__		,					lowercase__		,					lowercase__		,					unittest.TestCase    ):
      snake_case__       :  str       =		(
          (
              NezhaModel,
              NezhaForMaskedLM,
              NezhaForMultipleChoice,
              NezhaForNextSentencePrediction,
              NezhaForPreTraining,
              NezhaForQuestionAnswering,
              NezhaForSequenceClassification,
              NezhaForTokenClassification,
          )
          if is_torch_available()
          else ()
      )
      snake_case__       :  List[Any]       =		(
          {
              '''feature-extraction''': NezhaModel,
              '''fill-mask''': NezhaForMaskedLM,
              '''question-answering''': NezhaForQuestionAnswering,
              '''text-classification''': NezhaForSequenceClassification,
              '''token-classification''': NezhaForTokenClassification,
              '''zero-shot''': NezhaForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )
      snake_case__       :  List[str]       =		True
      def  SCREAMING_SNAKE_CASE							( self       : Union[str, Any]  ,							SCREAMING_SNAKE_CASE__       : int  ,							SCREAMING_SNAKE_CASE__       : str  ,							SCREAMING_SNAKE_CASE__       : Dict=False  )	->    Any:
             a_      :	Any							=						super()._prepare_for_class(SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							return_labels=SCREAMING_SNAKE_CASE__  )

             if return_labels:
                    if model_class in get_values(SCREAMING_SNAKE_CASE__  ):
                           a_      :	Any							=						torch.zeros(
                               (self.model_tester.batch_size, self.model_tester.seq_length)  ,							dtype=torch.long  ,							device=SCREAMING_SNAKE_CASE__  )
                           a_      :	str							=						torch.zeros(
                               self.model_tester.batch_size  ,							dtype=torch.long  ,							device=SCREAMING_SNAKE_CASE__  )
             return inputs_dict
      def  SCREAMING_SNAKE_CASE							( self       : List[Any]  )	->    str:
             a_      :	Optional[int]							=						NezhaModelTester(self  )
             a_      :	Tuple							=						ConfigTester(self  ,							config_class=SCREAMING_SNAKE_CASE__  ,							hidden_size=3_7  )
      def  SCREAMING_SNAKE_CASE							( self       : str  )	->    str:
             self.config_tester.run_common_tests()
      def  SCREAMING_SNAKE_CASE							( self       : Optional[Any]  )	->    str:
             a_      :	List[Any]							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : List[str]  )	->    int:
             a_      :	Union[str, Any]							=						self.model_tester.prepare_config_and_inputs_for_decoder()
             self.model_tester.create_and_check_model_as_decoder(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : str  )	->    Any:
             # This regression test was failing with PyTorch < 1.3
             (
                 (
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	(
                 a_
             )							,	
             )      :	List[str]							=						self.model_tester.prepare_config_and_inputs_for_decoder()

             a_      :	List[Any]							=						None

             self.model_tester.create_and_check_model_as_decoder(
                 SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  ,							)
      def  SCREAMING_SNAKE_CASE							( self       : int  )	->    Tuple:
             a_      :	int							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : Optional[Any]  )	->    Dict:
             a_      :	Dict							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : int  )	->    Optional[Any]:
             a_      :	List[str]							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_next_sequence_prediction(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : Dict  )	->    Optional[int]:
             a_      :	Dict							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : str  )	->    int:
             a_      :	List[Any]							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : List[str]  )	->    Tuple:
             a_      :	Dict							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__  )
      def  SCREAMING_SNAKE_CASE							( self       : str  )	->    int:
             a_      :	Any							=						self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE__  )
      @slow
      def  SCREAMING_SNAKE_CASE							( self       : int  )	->    str:
             for model_name in NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                    a_      :	Optional[Any]							=						NezhaModel.from_pretrained(SCREAMING_SNAKE_CASE__  )
                    self.assertIsNotNone(SCREAMING_SNAKE_CASE__  )

      @slow
      @require_torch_gpu
      def  SCREAMING_SNAKE_CASE							( self       : int  )	->    Dict:
             a_							,	a_      :	Tuple							=						self.model_tester.prepare_config_and_inputs_for_common()
             for model_class in self.all_model_classes:
                    # NezhaForMultipleChoice behaves incorrectly in JIT environments.
                    if model_class == NezhaForMultipleChoice:
                           return

                    a_      :	Optional[int]							=						True
                    a_      :	List[str]							=						model_class(config=SCREAMING_SNAKE_CASE__  )

                    a_      :	str							=						self._prepare_for_class(SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  )
                    a_      :	Any							=						torch.jit.trace(
                        SCREAMING_SNAKE_CASE__  ,							(inputs_dict['input_ids'].to('cpu'  ), inputs_dict['attention_mask'].to('cpu'  ))  )

                    with tempfile.TemporaryDirectory() as tmp:
                           torch.jit.save(SCREAMING_SNAKE_CASE__  ,							os.path.join(SCREAMING_SNAKE_CASE__  ,							'bert.pt'  )  )
                           a_      :	Any							=						torch.jit.load(os.path.join(SCREAMING_SNAKE_CASE__  ,							'bert.pt'  )  ,							map_location=SCREAMING_SNAKE_CASE__  )
                           loaded(inputs_dict['input_ids'].to(SCREAMING_SNAKE_CASE__  )  ,							inputs_dict['attention_mask'].to(SCREAMING_SNAKE_CASE__  )  )
@require_torch
class 				SCREAMING_SNAKE_CASE__						(       unittest.TestCase    ):
      @slow
      def  SCREAMING_SNAKE_CASE							( self       : Tuple  )	->    Union[str, Any]:
             a_      :	Union[str, Any]							=						NezhaModel.from_pretrained('sijunhe/nezha-cn-base'  )
             a_      :	Dict							=						torch.tensor([[0, 1, 2, 3, 4, 5]]  )
             a_      :	List[str]							=						torch.tensor([[0, 1, 1, 1, 1, 1]]  )
             with torch.no_grad():
                    a_      :	Optional[int]							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  )[0]
             a_      :	Any							=						torch.Size((1, 6, 7_6_8)  )
             self.assertEqual(output.shape  ,							SCREAMING_SNAKE_CASE__  )
             a_      :	int							=						torch.tensor([[[0.0685, 0.2441, 0.1102], [0.0600, 0.1906, 0.1349], [0.0221, 0.0819, 0.0586]]]  )

             self.assertTrue(torch.allclose(output[:, 1:4, 1:4]  ,							SCREAMING_SNAKE_CASE__  ,							atol=1E-4  )  )

      @slow
      def  SCREAMING_SNAKE_CASE							( self       : Any  )	->    Dict:
             a_      :	List[Any]							=						NezhaForMaskedLM.from_pretrained('sijunhe/nezha-cn-base'  )
             a_      :	str							=						torch.tensor([[0, 1, 2, 3, 4, 5]]  )
             a_      :	Any							=						torch.tensor([[1, 1, 1, 1, 1, 1]]  )
             with torch.no_grad():
                    a_      :	List[Any]							=						model(SCREAMING_SNAKE_CASE__  ,							attention_mask=SCREAMING_SNAKE_CASE__  )[0]
             a_      :	Optional[Any]							=						torch.Size((1, 6, 2_1_1_2_8)  )
             self.assertEqual(output.shape  ,							SCREAMING_SNAKE_CASE__  )
             a_      :	List[Any]							=						torch.tensor(
                 [[-2.7939, -1.7902, -2.2189], [-2.8585, -1.8908, -2.3723], [-2.6499, -1.7750, -2.2558]]  )

             self.assertTrue(torch.allclose(output[:, 1:4, 1:4]  ,							SCREAMING_SNAKE_CASE__  ,							atol=1E-4  )  )






def  SCREAMING_SNAKE_CASE_		(    __A				:    list       )			->	list:

       """simple docstring"""

       if len(__A       ) <= 1:
              return [tuple(__A       )]

       a_      :	Optional[Any]							=						[]

       def generate(__A				:    int						,					__A				:    list       ):
              a_      :	str							=						[0] * n
              res.append(tuple(__A       )       )

              a_      :	Optional[int]							=						0
              while i < n:
                     if c[i] < i:
                            if i % 2 == 0:
                                   a_							,	a_      :	Dict							=						arr[i], arr[0]
                            else:
                                   a_							,	a_      :	Union[str, Any]							=						arr[i], arr[c[i]]
                            res.append(tuple(__A       )       )
                            c[i] += 1
                            a_      :	Dict							=						0
                     else:
                            a_      :	Optional[Any]							=						0
                            i += 1

       generate(len(__A       )						,					__A       )
       return res


if __name__ == "__main__":
   UpperCAmelCase_   :				Union[str, Any]						      = input('Enter numbers separated by a comma:\n').strip()
   UpperCAmelCase_   :				Optional[Any]						      = [int(item) for item in user_input.split(',')]
   print(heaps(arr))


