import unittest

import numpy as np

from transformers import ElectraConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
 from transformers.models.electra.modeling_flax_electra import (
     FlaxElectraForCausalLM,
     FlaxElectraForMaskedLM,
     FlaxElectraForMultipleChoice,
     FlaxElectraForPreTraining,
     FlaxElectraForQuestionAnswering,
     FlaxElectraForSequenceClassification,
     FlaxElectraForTokenClassification,
     FlaxElectraModel,
 )

class 				_lowercase						(    unittest.TestCase ):






    '''simple docstring'''




    def __init__(						self					,	lowerCamelCase__					,	lowerCamelCase__=13					,	lowerCamelCase__=7					,	lowerCamelCase__=True					,	lowerCamelCase__=True					,	lowerCamelCase__=True					,	lowerCamelCase__=True					,	lowerCamelCase__=99					,	lowerCamelCase__=24					,	lowerCamelCase__=32					,	lowerCamelCase__=5					,	lowerCamelCase__=4					,	lowerCamelCase__=37					,	lowerCamelCase__="gelu"					,	lowerCamelCase__=0.1					,	lowerCamelCase__=0.1					,	lowerCamelCase__=512					,	lowerCamelCase__=16					,	lowerCamelCase__=2					,	lowerCamelCase__=0.0_2					,	lowerCamelCase__=4					,	):
       lowerCAmelCase_:       List[str]         =  parent
       lowerCAmelCase_:       Union[str, Any]         =  batch_size
       lowerCAmelCase_:       str         =  seq_length
       lowerCAmelCase_:       Any         =  is_training
       lowerCAmelCase_:       str         =  use_attention_mask
       lowerCAmelCase_:       List[Any]         =  use_token_type_ids
       lowerCAmelCase_:       List[Any]         =  use_labels
       lowerCAmelCase_:       Any         =  vocab_size
       lowerCAmelCase_:       Any         =  hidden_size
       lowerCAmelCase_:       Union[str, Any]         =  embedding_size
       lowerCAmelCase_:       Dict         =  num_hidden_layers
       lowerCAmelCase_:       List[Any]         =  num_attention_heads
       lowerCAmelCase_:       Optional[int]         =  intermediate_size
       lowerCAmelCase_:       Union[str, Any]         =  hidden_act
       lowerCAmelCase_:       Dict         =  hidden_dropout_prob
       lowerCAmelCase_:       Dict         =  attention_probs_dropout_prob
       lowerCAmelCase_:       Dict         =  max_position_embeddings
       lowerCAmelCase_:       Optional[Any]         =  type_vocab_size
       lowerCAmelCase_:       Optional[int]         =  type_sequence_label_size
       lowerCAmelCase_:       str         =  initializer_range
       lowerCAmelCase_:       Dict         =  num_choices




    def     _a						(						self   ):
       lowerCAmelCase_:       List[str]         =  ids_tensor([self.batch_size, self.seq_length]					,	self.vocab_size   )

       lowerCAmelCase_:       List[Any]         =  None
       if self.use_attention_mask:
          lowerCAmelCase_:       Dict         =  random_attention_mask([self.batch_size, self.seq_length]   )

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

       lowerCAmelCase_:       Any         =  ElectraConfig(
           vocab_size=self.vocab_size					,	hidden_size=self.hidden_size					,	embedding_size=self.embedding_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					,	)

       return config, input_ids, token_type_ids, attention_mask




    def     _a						(						self   ):
       lowerCAmelCase_:       List[Any]         =  self.prepare_config_and_inputs()
       lowerCAmelCase_:       Any         =  config_and_inputs
       lowerCAmelCase_:       Optional[int]         =  {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": attention_mask}
       return config, inputs_dict





@require_flax
class 				_lowercase						(    UpperCAmelCase__   ,     unittest.TestCase ):






    '''simple docstring'''
    SCREAMING_SNAKE_CASE:							Optional[int]        =						True

    SCREAMING_SNAKE_CASE:							Any        =						(
        (
            FlaxElectraModel,
            FlaxElectraForCausalLM,
            FlaxElectraForMaskedLM,
            FlaxElectraForPreTraining,
            FlaxElectraForTokenClassification,
            FlaxElectraForQuestionAnswering,
            FlaxElectraForMultipleChoice,
            FlaxElectraForSequenceClassification,
        )
        if is_flax_available()
        else ()
    )




    def     _a						(						self   ):
       lowerCAmelCase_:       List[Any]         =  FlaxElectraModelTester(self   )




    @slow
    def     _a						(						self   ):
       for model_class_name in self.all_model_classes:
          if model_class_name == FlaxElectraForMaskedLM:
             lowerCAmelCase_:       Tuple         =  model_class_name.from_pretrained("google/electra-small-generator"   )
          else:
             lowerCAmelCase_:       Optional[int]         =  model_class_name.from_pretrained("google/electra-small-discriminator"   )
          lowerCAmelCase_:       List[Any]         =  model(np.ones((1, 1)   )   )
          self.assertIsNotNone(lowerCamelCase__   )




import itertools
def 		snake_case__  (		lowercase				):
   return (
       int("".join(combination[0:2]				)				) * int("".join(combination[2:5]				)				)
       == int("".join(combination[5:9]				)				)
   ) or (
       int("".join(combination[0]				)				) * int("".join(combination[1:5]				)				)
       == int("".join(combination[5:9]				)				)
   )
def 		snake_case__  (		):
   return sum(
       {
           int("".join(pandigital[5:9]				)				)
           for pandigital in itertools.permutations("123456789"				)
           if is_combination_valid(lowercase				)
       }				)


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