


'''simple docstring'''



import unittest

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

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,
          ElectraForCausalLM,
          ElectraForMaskedLM,
          ElectraForMultipleChoice,
          ElectraForPreTraining,
          ElectraForQuestionAnswering,
          ElectraForSequenceClassification,
          ElectraForTokenClassification,
          ElectraModel,
      )
      from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST





class        UpperCAmelCase_  :





    """simple docstring"""






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







    def 				lowercase_    (							self     )    ->					List[str]:
         __lowerCamelCase       :     Tuple        =		ids_tensor([self.batch_size, self.seq_length]      ,					self.vocab_size     )

         __lowerCamelCase       :     str        =		None
         if self.use_input_mask:
              __lowerCamelCase       :     Optional[int]        =		random_attention_mask([self.batch_size, self.seq_length]     )

         __lowerCamelCase       :     List[str]        =		None
         if self.use_token_type_ids:
              __lowerCamelCase       :     int        =		ids_tensor([self.batch_size, self.seq_length]      ,					self.type_vocab_size     )

         __lowerCamelCase       :     Tuple        =		None
         __lowerCamelCase       :     Any        =		None
         __lowerCamelCase       :     List[str]        =		None
         if self.use_labels:
              __lowerCamelCase       :     Optional[Any]        =		ids_tensor([self.batch_size]      ,					self.type_sequence_label_size     )
              __lowerCamelCase       :     int        =		ids_tensor([self.batch_size, self.seq_length]      ,					self.num_labels     )
              __lowerCamelCase       :     int        =		ids_tensor([self.batch_size]      ,					self.num_choices     )
              __lowerCamelCase       :     Optional[int]        =		ids_tensor([self.batch_size, self.seq_length]      ,					1     )

         __lowerCamelCase       :     List[Any]        =		self.get_config()

         return (
             config,
             input_ids,
             token_type_ids,
             input_mask,
             sequence_labels,
             token_labels,
             choice_labels,
             fake_token_labels,
         )







    def 				lowercase_    (							self     )    ->					List[Any]:
         return ElectraConfig(
             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 				lowercase_    (							self     )    ->					str:
         (
             (
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	
         )       :     Optional[Any]        =		self.prepare_config_and_inputs()

         __lowerCamelCase       :     int        =		True
         __lowerCamelCase       :     Optional[int]        =		floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
         __lowerCamelCase       :     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 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					Optional[int]:
         __lowerCamelCase       :     str        =		ElectraModel(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     Optional[int]        =		model(SCREAMING_SNAKE_CASE_      ,					attention_mask=SCREAMING_SNAKE_CASE_      ,					token_type_ids=SCREAMING_SNAKE_CASE_     )
         __lowerCamelCase       :     Tuple        =		model(SCREAMING_SNAKE_CASE_      ,					token_type_ids=SCREAMING_SNAKE_CASE_     )
         __lowerCamelCase       :     int        =		model(SCREAMING_SNAKE_CASE_     )
         self.parent.assertEqual(result.last_hidden_state.shape      ,					(self.batch_size, self.seq_length, self.hidden_size)     )







    def 				lowercase_    (							self      ,					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_      ,					)    ->					Optional[Any]:
         __lowerCamelCase       :     List[Any]        =		True
         __lowerCamelCase       :     str        =		ElectraModel(SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     List[str]        =		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_      ,					)
         __lowerCamelCase       :     Optional[Any]        =		model(
             SCREAMING_SNAKE_CASE_      ,					attention_mask=SCREAMING_SNAKE_CASE_      ,					token_type_ids=SCREAMING_SNAKE_CASE_      ,					encoder_hidden_states=SCREAMING_SNAKE_CASE_      ,					)
         __lowerCamelCase       :     Tuple        =		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)     )







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					List[str]:
         __lowerCamelCase       :     List[Any]        =		ElectraForMaskedLM(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     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, self.seq_length, self.vocab_size)     )







    def 				lowercase_    (							self      ,					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_      ,					)    ->					Optional[int]:
         __lowerCamelCase       :     Optional[Any]        =		ElectraForCausalLM(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     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.seq_length, self.vocab_size)     )







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					List[Any]:
         __lowerCamelCase       :     str        =		self.num_labels
         __lowerCamelCase       :     Optional[int]        =		ElectraForTokenClassification(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     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 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					Optional[Any]:
         __lowerCamelCase       :     Union[str, Any]        =		self.num_labels
         __lowerCamelCase       :     Tuple        =		ElectraForPreTraining(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     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)     )







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					Optional[int]:
         __lowerCamelCase       :     Union[str, Any]        =		self.num_labels
         __lowerCamelCase       :     List[str]        =		ElectraForSequenceClassification(SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     Tuple        =		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 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					Optional[Any]:
         __lowerCamelCase       :     Dict        =		ElectraForQuestionAnswering(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     Any        =		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 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					)    ->					str:
         __lowerCamelCase       :     Tuple        =		self.num_choices
         __lowerCamelCase       :     int        =		ElectraForMultipleChoice(config=SCREAMING_SNAKE_CASE_     )
         model.to(SCREAMING_SNAKE_CASE_     )
         model.eval()
         __lowerCamelCase       :     str        =		input_ids.unsqueeze(1     ).expand(-1      ,					self.num_choices      ,					-1     ).contiguous()
         __lowerCamelCase       :     Dict        =		token_type_ids.unsqueeze(1     ).expand(-1      ,					self.num_choices      ,					-1     ).contiguous()
         __lowerCamelCase       :     Union[str, Any]        =		input_mask.unsqueeze(1     ).expand(-1      ,					self.num_choices      ,					-1     ).contiguous()
         __lowerCamelCase       :     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.num_choices)     )







    def 				lowercase_    (							self     )    ->					Union[str, Any]:
         __lowerCamelCase       :     Optional[Any]        =		self.prepare_config_and_inputs()
         (
             (
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	(
             __lowerCamelCase
         )    ,	
         )       :     Optional[int]        =		config_and_inputs
         __lowerCamelCase       :     str        =		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
         return config, inputs_dict







@require_torch
class        UpperCAmelCase_  (_UpperCAmelCase ,		_UpperCAmelCase ,		unittest.TestCase  ):





    """simple docstring"""






    lowerCamelCase  : Optional[Any]												=      (
        (
            ElectraModel,
            ElectraForPreTraining,
            ElectraForMaskedLM,
            ElectraForCausalLM,
            ElectraForMultipleChoice,
            ElectraForTokenClassification,
            ElectraForSequenceClassification,
            ElectraForQuestionAnswering,
        )
        if is_torch_available()
        else ()
    )
    lowerCamelCase  : str												=      (
        {
            'feature-extraction': ElectraModel,
            'fill-mask': ElectraForMaskedLM,
            'question-answering': ElectraForQuestionAnswering,
            'text-classification': ElectraForSequenceClassification,
            'text-generation': ElectraForCausalLM,
            'token-classification': ElectraForTokenClassification,
            'zero-shot': ElectraForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    lowerCamelCase  : Union[str, Any]												=      True







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_=False     )    ->					Union[str, Any]:
         __lowerCamelCase       :     Tuple        =		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_     ):
                   __lowerCamelCase       :     Any        =		torch.zeros(
                       (self.model_tester.batch_size, self.model_tester.seq_length)      ,					dtype=torch.long      ,					device=SCREAMING_SNAKE_CASE_     )
         return inputs_dict







    def 				lowercase_    (							self     )    ->					int:
         __lowerCamelCase       :     Optional[int]        =		ElectraModelTester(self     )
         __lowerCamelCase       :     int        =		ConfigTester(self      ,					config_class=SCREAMING_SNAKE_CASE_      ,					hidden_size=37     )







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







    def 				lowercase_    (							self     )    ->					Any:
         __lowerCamelCase       :     Union[str, Any]        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_model(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					List[str]:
         __lowerCamelCase       :     Optional[int]        =		self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_electra_model_as_decoder(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					str:
         __lowerCamelCase       :     Optional[Any]        =		self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
              __lowerCamelCase       :     List[str]        =		type
              self.model_tester.create_and_check_electra_model(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					str:
         __lowerCamelCase       :     Optional[Any]        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_masked_lm(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					Optional[int]:
         __lowerCamelCase       :     Optional[int]        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_token_classification(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					Optional[int]:
         __lowerCamelCase       :     Tuple        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_pretraining(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					Dict:
         __lowerCamelCase       :     Union[str, Any]        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_sequence_classification(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					Dict:
         __lowerCamelCase       :     Union[str, Any]        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_question_answering(*SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					List[str]:
         __lowerCamelCase       :     List[Any]        =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_multiple_choice(*SCREAMING_SNAKE_CASE_     )







    @slow
    def 				lowercase_    (							self     )    ->					Union[str, Any]:
         for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __lowerCamelCase       :     int        =		ElectraModel.from_pretrained(SCREAMING_SNAKE_CASE_     )
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self     )    ->					List[str]:
         __lowerCamelCase       :     Optional[int]        =		self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_electra_for_causal_lm(*SCREAMING_SNAKE_CASE_     )







@require_torch
class        UpperCAmelCase_  (unittest.TestCase  ):





    """simple docstring"""






    @slow
    def 				lowercase_    (							self     )    ->					Union[str, Any]:
         __lowerCamelCase       :     Union[str, Any]        =		ElectraModel.from_pretrained('google/electra-small-discriminator'     )
         __lowerCamelCase       :     Union[str, Any]        =		torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]     )
         __lowerCamelCase       :     Any        =		torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]     )
         __lowerCamelCase       :     Dict        =		model(SCREAMING_SNAKE_CASE_      ,					attention_mask=SCREAMING_SNAKE_CASE_     )[0]
         __lowerCamelCase       :     List[str]        =		torch.Size((1, 11, 2_56)     )
         self.assertEqual(output.shape      ,					SCREAMING_SNAKE_CASE_     )
         __lowerCamelCase       :     Optional[Any]        =		torch.tensor(
             [[[0.4_4_7_1, 0.6_8_2_1, -0.3_2_6_5], [0.4_6_2_7, 0.5_2_5_5, -0.3_6_6_8], [0.4_5_3_2, 0.3_3_1_3, -0.4_3_4_4]]]     )

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










'''simple docstring'''



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int = 4_00_00_00							)					->		int:
     __lowerCamelCase       :     int        =		1
     __lowerCamelCase       :     Union[str, Any]        =		2
     __lowerCamelCase       :     Optional[int]        =		0
     while j <= n:
          if j % 2 == 0:
               total += j
          __lowerCamelCase    ,	__lowerCamelCase       :     List[Any]        =		j, i + j

     return total


if __name__ == "__main__":
      print(f'''{solution() = }''')






