

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 			snake_case_     (	unittest.TestCase      ):







			'''simple docstring'''

			def __init__(  self				:       Optional[int]							,     _UpperCamelCase				:       int							,     _UpperCamelCase				:       Optional[Any]=1_3							,     _UpperCamelCase				:       Any=7							,     _UpperCamelCase				:       Optional[int]=True							,     _UpperCamelCase				:       List[Any]=True							,     _UpperCamelCase				:       int=True							,     _UpperCamelCase				:       Union[str, Any]=True							,     _UpperCamelCase				:       List[str]=9_9							,     _UpperCamelCase				:       int=2_4							,     _UpperCamelCase				:       int=3_2							,     _UpperCamelCase				:       Any=5							,     _UpperCamelCase				:       List[Any]=4							,     _UpperCamelCase				:       int=3_7							,     _UpperCamelCase				:       Tuple="gelu"							,     _UpperCamelCase				:       List[str]=0.1							,     _UpperCamelCase				:       List[str]=0.1							,     _UpperCamelCase				:       int=5_1_2							,     _UpperCamelCase				:       Union[str, Any]=1_6							,     _UpperCamelCase				:       Tuple=2							,     _UpperCamelCase				:       List[str]=0.02							,     _UpperCamelCase				:       Optional[int]=4							,     )   ->Any:
									snake_case_     =			parent
									snake_case_     =			batch_size
									snake_case_     =			seq_length
									snake_case_     =			is_training
									snake_case_     =			use_attention_mask
									snake_case_     =			use_token_type_ids
									snake_case_     =			use_labels
									snake_case_     =			vocab_size
									snake_case_     =			hidden_size
									snake_case_     =			embedding_size
									snake_case_     =			num_hidden_layers
									snake_case_     =			num_attention_heads
									snake_case_     =			intermediate_size
									snake_case_     =			hidden_act
									snake_case_     =			hidden_dropout_prob
									snake_case_     =			attention_probs_dropout_prob
									snake_case_     =			max_position_embeddings
									snake_case_     =			type_vocab_size
									snake_case_     =			type_sequence_label_size
									snake_case_     =			initializer_range
									snake_case_     =			num_choices







			def        snake_case__(  self				:       str							)   ->Any:
									snake_case_     =			ids_tensor([self.batch_size, self.seq_length]							,     self.vocab_size							)

									snake_case_     =			None
									if self.use_attention_mask:
															snake_case_     =			random_attention_mask([self.batch_size, self.seq_length]							)

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

									snake_case_     =			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        snake_case__(  self				:       str							)   ->Optional[Any]:
									snake_case_     =			self.prepare_config_and_inputs()
									snake_case_,					snake_case_,					snake_case_,					snake_case_     =			config_and_inputs
									snake_case_     =			{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
									return config, inputs_dict






@require_flax
class 			snake_case_     (	__A			, unittest.TestCase      ):







			'''simple docstring'''

			SCREAMING_SNAKE_CASE  :     Any		    =       True

			SCREAMING_SNAKE_CASE  :     List[str]		    =       (
			    (
			        FlaxElectraModel,
			        FlaxElectraForCausalLM,
			        FlaxElectraForMaskedLM,
			        FlaxElectraForPreTraining,
			        FlaxElectraForTokenClassification,
			        FlaxElectraForQuestionAnswering,
			        FlaxElectraForMultipleChoice,
			        FlaxElectraForSequenceClassification,
			    )
			    if is_flax_available()
			    else ()
			)







			def        snake_case__(  self				:       List[str]							)   ->Dict:
									snake_case_     =			FlaxElectraModelTester(self							)







			@slow
			def        snake_case__(  self				:       Dict							)   ->Optional[Any]:
									for model_class_name in self.all_model_classes:
															if model_class_name == FlaxElectraForMaskedLM:
																					snake_case_     =			model_class_name.from_pretrained('''google/electra-small-generator'''							)
															else:
																					snake_case_     =			model_class_name.from_pretrained('''google/electra-small-discriminator'''							)
															snake_case_     =			model(np.ones((1, 1)							)							)
															self.assertIsNotNone(_UpperCamelCase							)


import warnings

from .generation import GenerationMixin





class 			snake_case_     (	__A      ):







			'''simple docstring'''

			warnings.warn(
			    "Importing `GenerationMixin` from `src/transformers/generation_utils.py` is deprecated and will "
			    "be removed in Transformers v5. Import as `from transformers import GenerationMixin` instead."			, __A			, )