

"""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     :
			def __init__(						self ,						_A ,						_A=13 ,						_A=7 ,						_A=True ,						_A=True ,						_A=True ,						_A=True ,						_A=99 ,						_A=32 ,						_A=5 ,						_A=4 ,						_A=37 ,						_A="gelu" ,						_A=0.1 ,						_A=0.1 ,						_A=5_12 ,						_A=16 ,						_A=2 ,						_A=0.02 ,						_A=3 ,						_A=4 ,						_A=None ,						)      ->      Dict:






				'''simple docstring'''







				_UpperCAmelCase      :							Union[str, Any]       =   parent
				_UpperCAmelCase      :							Any       =   batch_size
				_UpperCAmelCase      :							int       =   seq_length
				_UpperCAmelCase      :							Optional[Any]       =   is_training
				_UpperCAmelCase      :							str       =   use_input_mask
				_UpperCAmelCase      :							Dict       =   use_token_type_ids
				_UpperCAmelCase      :							Tuple       =   use_labels
				_UpperCAmelCase      :							Union[str, Any]       =   vocab_size
				_UpperCAmelCase      :							Dict       =   hidden_size
				_UpperCAmelCase      :							int       =   num_hidden_layers
				_UpperCAmelCase      :							Union[str, Any]       =   num_attention_heads
				_UpperCAmelCase      :							List[str]       =   intermediate_size
				_UpperCAmelCase      :							Any       =   hidden_act
				_UpperCAmelCase      :							Any       =   hidden_dropout_prob
				_UpperCAmelCase      :							Any       =   attention_probs_dropout_prob
				_UpperCAmelCase      :							List[str]       =   max_position_embeddings
				_UpperCAmelCase      :							Optional[Any]       =   type_vocab_size
				_UpperCAmelCase      :							Dict       =   type_sequence_label_size
				_UpperCAmelCase      :							Tuple       =   initializer_range
				_UpperCAmelCase      :							Optional[Any]       =   num_labels
				_UpperCAmelCase      :							int       =   num_choices
				_UpperCAmelCase      :							str       =   scope
			def 							__snake_case	(						self       )      ->      Dict:






				'''simple docstring'''







				_UpperCAmelCase      :							Union[str, Any]       =   ids_tensor([self.batch_size, self.seq_length] ,						self.vocab_size       )

				_UpperCAmelCase      :							str       =   None
				if self.use_input_mask:
					_UpperCAmelCase      :							Any       =   random_attention_mask([self.batch_size, self.seq_length]       )

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

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

				_UpperCAmelCase      :							Tuple       =   self.get_config()

				return (
				    config,
				    input_ids,
				    token_type_ids,
				    input_mask,
				    sequence_labels,
				    token_labels,
				    choice_labels,
				    fake_token_labels,
				)
			def 							__snake_case	(						self       )      ->      Union[str, Any]:






				'''simple docstring'''







				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=__A ,						initializer_range=self.initializer_range ,						)
			def 							__snake_case	(						self       )      ->      int:






				'''simple docstring'''







				(
				    _UpperCAmelCase     
				)      :							Optional[Any]       =   self.prepare_config_and_inputs()

				_UpperCAmelCase      :							Any       =   True
				_UpperCAmelCase      :							Dict       =   floats_tensor([self.batch_size, self.seq_length, self.hidden_size]       )
				_UpperCAmelCase      :							Union[str, Any]       =   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 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      List[str]:






				'''simple docstring'''







				_UpperCAmelCase      :							Tuple       =   ElectraModel(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							str       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A       )
				_UpperCAmelCase      :							List[Any]       =   model(__A ,						token_type_ids=__A       )
				_UpperCAmelCase      :							Optional[Any]       =   model(__A       )
				self.parent.assertEqual(result.last_hidden_state.shape ,						(self.batch_size, self.seq_length, self.hidden_size)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      int:






				'''simple docstring'''







				_UpperCAmelCase      :							Optional[int]       =   True
				_UpperCAmelCase      :							Dict       =   ElectraModel(__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							Optional[Any]       =   model(
				    __A ,						attention_mask=__A ,						token_type_ids=__A ,						encoder_hidden_states=__A ,						encoder_attention_mask=__A ,						)
				_UpperCAmelCase      :							Optional[Any]       =   model(
				    __A ,						attention_mask=__A ,						token_type_ids=__A ,						encoder_hidden_states=__A ,						)
				_UpperCAmelCase      :							List[Any]       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A       )
				self.parent.assertEqual(result.last_hidden_state.shape ,						(self.batch_size, self.seq_length, self.hidden_size)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      Dict:






				'''simple docstring'''







				_UpperCAmelCase      :							Tuple       =   ElectraForMaskedLM(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							Dict       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A ,						labels=__A       )
				self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.seq_length, self.vocab_size)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      int:






				'''simple docstring'''







				_UpperCAmelCase      :							Dict       =   ElectraForCausalLM(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							Optional[int]       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A ,						labels=__A       )
				self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.seq_length, self.vocab_size)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      List[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							Optional[Any]       =   self.num_labels
				_UpperCAmelCase      :							Dict       =   ElectraForTokenClassification(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							Union[str, Any]       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A ,						labels=__A       )
				self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.seq_length, self.num_labels)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      Any:






				'''simple docstring'''







				_UpperCAmelCase      :							Any       =   self.num_labels
				_UpperCAmelCase      :							List[str]       =   ElectraForPreTraining(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							int       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A ,						labels=__A       )
				self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.seq_length)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      Optional[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							List[str]       =   self.num_labels
				_UpperCAmelCase      :							Tuple       =   ElectraForSequenceClassification(__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							Dict       =   model(__A ,						attention_mask=__A ,						token_type_ids=__A ,						labels=__A       )
				self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.num_labels)       )
			def 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      Optional[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							Optional[Any]       =   ElectraForQuestionAnswering(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							str       =   model(
				    __A ,						attention_mask=__A ,						token_type_ids=__A ,						start_positions=__A ,						end_positions=__A ,						)
				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 							__snake_case	(						self ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						_A ,						)      ->      Any:






				'''simple docstring'''







				_UpperCAmelCase      :							str       =   self.num_choices
				_UpperCAmelCase      :							List[Any]       =   ElectraForMultipleChoice(config=__A       )
				model.to(__A       )
				model.eval()
				_UpperCAmelCase      :							str       =   input_ids.unsqueeze(1       ).expand(-1 ,						self.num_choices ,						-1       ).contiguous()
				_UpperCAmelCase      :							List[str]       =   token_type_ids.unsqueeze(1       ).expand(-1 ,						self.num_choices ,						-1       ).contiguous()
				_UpperCAmelCase      :							Dict       =   input_mask.unsqueeze(1       ).expand(-1 ,						self.num_choices ,						-1       ).contiguous()
				_UpperCAmelCase      :							Any       =   model(
				    __A ,						attention_mask=__A ,						token_type_ids=__A ,						labels=__A ,						)
				self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.num_choices)       )
			def 							__snake_case	(						self       )      ->      Dict:






				'''simple docstring'''







				_UpperCAmelCase      :							Any       =   self.prepare_config_and_inputs()
				(
				    _UpperCAmelCase     
				)      :							Union[str, Any]       =   config_and_inputs
				_UpperCAmelCase      :							Optional[int]       =   {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
				return config, inputs_dict
@require_torch
class       _UpperCAmelCase     (						__a      ,       __a      ,       unittest.TestCase):
			__a	:    Optional[Any]			   =							(
			    (
			        ElectraModel,
			        ElectraForPreTraining,
			        ElectraForMaskedLM,
			        ElectraForCausalLM,
			        ElectraForMultipleChoice,
			        ElectraForTokenClassification,
			        ElectraForSequenceClassification,
			        ElectraForQuestionAnswering,
			    )
			    if is_torch_available()
			    else ()
			)
			__a	:    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 {}
			)
			__a	:    int			   =							True
			def 							__snake_case	(						self ,						_A ,						_A ,						_A=False       )      ->      List[str]:






				'''simple docstring'''







				_UpperCAmelCase      :							List[Any]       =   super()._prepare_for_class(__A ,						__A ,						return_labels=__A       )

				if return_labels:
					if model_class in get_values(__A       ):
						_UpperCAmelCase      :							List[str]       =   torch.zeros(
						    (self.model_tester.batch_size, self.model_tester.seq_length) ,						dtype=torch.long ,						device=__A       )
				return inputs_dict
			def 							__snake_case	(						self       )      ->      Union[str, Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							List[str]       =   ElectraModelTester(self       )
				_UpperCAmelCase      :							int       =   ConfigTester(self ,						config_class=__A ,						hidden_size=37       )
			def 							__snake_case	(						self       )      ->      str:






				'''simple docstring'''







				self.config_tester.run_common_tests()
			def 							__snake_case	(						self       )      ->      Dict:






				'''simple docstring'''







				_UpperCAmelCase      :							Optional[int]       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_model(*__A       )
			def 							__snake_case	(						self       )      ->      Tuple:






				'''simple docstring'''







				_UpperCAmelCase      :							List[Any]       =   self.model_tester.prepare_config_and_inputs_for_decoder()
				self.model_tester.create_and_check_electra_model_as_decoder(*__A       )
			def 							__snake_case	(						self       )      ->      Optional[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							Tuple       =   self.model_tester.prepare_config_and_inputs()
				for type in ["absolute", "relative_key", "relative_key_query"]:
					_UpperCAmelCase      :							Union[str, Any]       =   type
					self.model_tester.create_and_check_electra_model(*__A       )
			def 							__snake_case	(						self       )      ->      Union[str, Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							List[Any]       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_for_masked_lm(*__A       )
			def 							__snake_case	(						self       )      ->      int:






				'''simple docstring'''







				_UpperCAmelCase      :							Tuple       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_for_token_classification(*__A       )
			def 							__snake_case	(						self       )      ->      List[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							Optional[Any]       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_for_pretraining(*__A       )
			def 							__snake_case	(						self       )      ->      Optional[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							int       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_for_sequence_classification(*__A       )
			def 							__snake_case	(						self       )      ->      List[str]:






				'''simple docstring'''







				_UpperCAmelCase      :							Tuple       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_for_question_answering(*__A       )
			def 							__snake_case	(						self       )      ->      Optional[int]:






				'''simple docstring'''







				_UpperCAmelCase      :							Dict       =   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_electra_for_multiple_choice(*__A       )
			@slow
			def 							__snake_case	(						self       )      ->      str:






				'''simple docstring'''







				for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
					_UpperCAmelCase      :							str       =   ElectraModel.from_pretrained(__A       )
					self.assertIsNotNone(__A       )
			def 							__snake_case	(						self       )      ->      Optional[Any]:






				'''simple docstring'''







				_UpperCAmelCase      :							Optional[Any]       =   self.model_tester.prepare_config_and_inputs_for_decoder()
				self.model_tester.create_and_check_electra_for_causal_lm(*__A       )
@require_torch
class       _UpperCAmelCase     (						unittest.TestCase):
			@slow
			def 							__snake_case	(						self       )      ->      Tuple:






				'''simple docstring'''







				_UpperCAmelCase      :							Union[str, Any]       =   ElectraModel.from_pretrained("""google/electra-small-discriminator"""       )
				_UpperCAmelCase      :							Optional[Any]       =   torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]       )
				_UpperCAmelCase      :							str       =   torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]       )
				_UpperCAmelCase      :							Optional[int]       =   model(__A ,						attention_mask=__A       )[0]
				_UpperCAmelCase      :							Optional[Any]       =   torch.Size((1, 11, 2_56)       )
				self.assertEqual(output.shape ,						__A       )
				_UpperCAmelCase      :							int       =   torch.tensor(
				    [[[0.4471, 0.6821, -0.3265], [0.4627, 0.5255, -0.3668], [0.4532, 0.3313, -0.4344]]]       )

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








"""simple docstring"""






from math import factorial
def  UpperCamelCase   (     _lowerCAmelCase       :  Dict,					_lowerCAmelCase       :  List[str]	)			->     Dict:
	return factorial(_lowerCAmelCase	) / (factorial(_lowerCAmelCase	) * factorial(n - r	))
def  UpperCamelCase   (     )			->     Tuple:
	_UpperCAmelCase      :							Optional[int]       =   0

	for i in range(1,					101	):
		for j in range(1,					i + 1	):
			if combinations(_lowerCAmelCase,					_lowerCAmelCase	) > 1E6:
				total += 1
	return total


if __name__ == "__main__":
						print(solution())





