






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:				Any   ,				__UpperCAmelCase:				List[Any]   ,				__UpperCAmelCase:				Optional[int]=13   ,				__UpperCAmelCase:				Any=7   ,				__UpperCAmelCase:				List[Any]=True   ,				__UpperCAmelCase:				Optional[Any]=True   ,				__UpperCAmelCase:				Dict=True   ,				__UpperCAmelCase:				int=True   ,				__UpperCAmelCase:				Any=99   ,				__UpperCAmelCase:				List[str]=24   ,				__UpperCAmelCase:				Dict=32   ,				__UpperCAmelCase:				Dict=5   ,				__UpperCAmelCase:				Tuple=4   ,				__UpperCAmelCase:				str=37   ,				__UpperCAmelCase:				Union[str, Any]="gelu"   ,				__UpperCAmelCase:				Any=0.1   ,				__UpperCAmelCase:				Dict=0.1   ,				__UpperCAmelCase:				List[Any]=512   ,				__UpperCAmelCase:				Tuple=16   ,				__UpperCAmelCase:				Tuple=2   ,				__UpperCAmelCase:				List[str]=0.02   ,				__UpperCAmelCase:				Optional[Any]=4   ,				)						->    int:




											'''simple docstring'''



											__a				:	List[Any]			=				parent
											__a				:	Dict			=				batch_size
											__a				:	List[str]			=				seq_length
											__a				:	str			=				is_training
											__a				:	Optional[Any]			=				use_attention_mask
											__a				:	Tuple			=				use_token_type_ids
											__a				:	List[str]			=				use_labels
											__a				:	List[Any]			=				vocab_size
											__a				:	Union[str, Any]			=				hidden_size
											__a				:	Tuple			=				embedding_size
											__a				:	Any			=				num_hidden_layers
											__a				:	Optional[int]			=				num_attention_heads
											__a				:	Dict			=				intermediate_size
											__a				:	Optional[int]			=				hidden_act
											__a				:	Dict			=				hidden_dropout_prob
											__a				:	List[Any]			=				attention_probs_dropout_prob
											__a				:	Optional[int]			=				max_position_embeddings
											__a				:	Optional[Any]			=				type_vocab_size
											__a				:	Dict			=				type_sequence_label_size
											__a				:	Optional[int]			=				initializer_range
											__a				:	Tuple			=				num_choices



						def 					UpperCAmelCase__				(self:				Dict      )						->    Optional[int]:




											'''simple docstring'''



											__a				:	Tuple			=				ids_tensor([self.batch_size, self.seq_length]   ,				self.vocab_size      )

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

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

											__a				:	Optional[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 					UpperCAmelCase__				(self:				Optional[Any]      )						->    List[Any]:




											'''simple docstring'''



											__a				:	Dict			=				self.prepare_config_and_inputs()
											__a			, __a			, __a			, __a				:	Optional[int]			=				config_and_inputs
											__a				:	Union[str, Any]			=				{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": attention_mask}
											return config, inputs_dict




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

						"""simple docstring"""



						snake_case__   					=			True

						snake_case__   					=			(
						    (
						        FlaxElectraModel,
						        FlaxElectraForCausalLM,
						        FlaxElectraForMaskedLM,
						        FlaxElectraForPreTraining,
						        FlaxElectraForTokenClassification,
						        FlaxElectraForQuestionAnswering,
						        FlaxElectraForMultipleChoice,
						        FlaxElectraForSequenceClassification,
						    )
						    if is_flax_available()
						    else ()
						)



						def 					UpperCAmelCase__				(self:				List[Any]      )						->    Optional[int]:




											'''simple docstring'''



											__a				:	int			=				FlaxElectraModelTester(self      )



						@slow
						def 					UpperCAmelCase__				(self:				Union[str, Any]      )						->    Optional[int]:




											'''simple docstring'''



											for model_class_name in self.all_model_classes:
																if model_class_name == FlaxElectraForMaskedLM:
																					__a				:	List[str]			=				model_class_name.from_pretrained("google/electra-small-generator"      )
																else:
																					__a				:	Any			=				model_class_name.from_pretrained("google/electra-small-discriminator"      )
																__a				:	str			=				model(np.ones((1, 1)      )      )
																self.assertIsNotNone(__UpperCAmelCase      )













import warnings

from .generation import GenerationMixin




class        snake_case_					(						__UpperCamelCase			):

						"""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."""		,       __UpperCamelCase		,       )





