



'''simple docstring'''







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






			def __init__(   self  :							List[Any]      ,       SCREAMING_SNAKE_CASE  :							Any      ,       SCREAMING_SNAKE_CASE  :							str=13      ,       SCREAMING_SNAKE_CASE  :							str=7      ,       SCREAMING_SNAKE_CASE  :							Tuple=True      ,       SCREAMING_SNAKE_CASE  :							List[str]=True      ,       SCREAMING_SNAKE_CASE  :							Optional[int]=True      ,       SCREAMING_SNAKE_CASE  :							List[str]=True      ,       SCREAMING_SNAKE_CASE  :							str=99      ,       SCREAMING_SNAKE_CASE  :							Optional[int]=24      ,       SCREAMING_SNAKE_CASE  :							str=32      ,       SCREAMING_SNAKE_CASE  :							List[str]=5      ,       SCREAMING_SNAKE_CASE  :							Optional[Any]=4      ,       SCREAMING_SNAKE_CASE  :							List[str]=37      ,       SCREAMING_SNAKE_CASE  :							Any="gelu"      ,       SCREAMING_SNAKE_CASE  :							Union[str, Any]=0.1      ,       SCREAMING_SNAKE_CASE  :							Dict=0.1      ,       SCREAMING_SNAKE_CASE  :							Dict=512      ,       SCREAMING_SNAKE_CASE  :							int=16      ,       SCREAMING_SNAKE_CASE  :							List[Any]=2      ,       SCREAMING_SNAKE_CASE  :							int=0.02      ,       SCREAMING_SNAKE_CASE  :							int=4      ,       ):




					"""simple docstring"""







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






			def 				_lowercase	(   self  :							List[str]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:List[str]										=      ids_tensor([self.batch_size, self.seq_length]      ,       self.vocab_size	)

					SCREAMING_SNAKE_CASE_						:Optional[int]										=      None
					if self.use_attention_mask:
							SCREAMING_SNAKE_CASE_						:Any										=      random_attention_mask([self.batch_size, self.seq_length]	)

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

					SCREAMING_SNAKE_CASE_						:str										=      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 				_lowercase	(   self  :							str	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Dict										=      self.prepare_config_and_inputs()
					SCREAMING_SNAKE_CASE_						:List[Any]										=      config_and_inputs
					SCREAMING_SNAKE_CASE_						:List[Any]										=      {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
					return config, inputs_dict




@require_flax
class 				__lowerCAmelCase(							a__		,			unittest.TestCase      ):
			__snake_case  :		Any		=      True

			__snake_case  :		Optional[int]		=      (
			    (
			        FlaxElectraModel,
			        FlaxElectraForCausalLM,
			        FlaxElectraForMaskedLM,
			        FlaxElectraForPreTraining,
			        FlaxElectraForTokenClassification,
			        FlaxElectraForQuestionAnswering,
			        FlaxElectraForMultipleChoice,
			        FlaxElectraForSequenceClassification,
			    )
			    if is_flax_available()
			    else ()
			)






			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:List[Any]										=      FlaxElectraModelTester(self	)






			@slow
			def 				_lowercase	(   self  :							List[Any]	):




					"""simple docstring"""







					for model_class_name in self.all_model_classes:
							if model_class_name == FlaxElectraForMaskedLM:
									SCREAMING_SNAKE_CASE_						:int										=      model_class_name.from_pretrained('google/electra-small-generator'	)
							else:
									SCREAMING_SNAKE_CASE_						:Dict										=      model_class_name.from_pretrained('google/electra-small-discriminator'	)
							SCREAMING_SNAKE_CASE_						:str										=      model(np.ones((1, 1)	)	)
							self.assertIsNotNone(_lowerCamelCase	)






'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


snake_case__ 							=    logging.get_logger(__name__)

snake_case__ 							=    {
    """uw-madison/nystromformer-512""": """https://huggingface.co/uw-madison/nystromformer-512/resolve/main/config.json""",
    # See all Nystromformer models at https://huggingface.co/models?filter=nystromformer
}






class      UpperCamelCase_  (a__  ):







						"""simple docstring"""


						_lowerCAmelCase         =       'nystromformer'







						def __init__(  self   :							Optional[Any]				,			_lowerCamelCase   :							str=30000				,			_lowerCamelCase   :							Optional[Any]=768				,			_lowerCamelCase   :							Optional[Any]=12				,			_lowerCamelCase   :							str=12				,			_lowerCamelCase   :							List[str]=3072				,			_lowerCamelCase   :							Any="gelu_new"				,			_lowerCamelCase   :							List[Any]=0.1				,			_lowerCamelCase   :							List[str]=0.1				,			_lowerCamelCase   :							List[str]=510				,			_lowerCamelCase   :							Optional[Any]=2				,			_lowerCamelCase   :							List[Any]=64				,			_lowerCamelCase   :							str=64				,			_lowerCamelCase   :							str=65				,			_lowerCamelCase   :							List[Any]=False				,			_lowerCamelCase   :							List[Any]=0.02				,			_lowerCamelCase   :							List[Any]=1E-5				,			_lowerCamelCase   :							Dict=1				,			_lowerCamelCase   :							Tuple=0				,			_lowerCamelCase   :							List[str]=2				,			**_lowerCamelCase   :							List[str]				,			):





											"""simple docstring"""







											A_			:  List[Any]			=				vocab_size
											A_			:  Tuple			=				max_position_embeddings
											A_			:  Dict			=				hidden_size
											A_			:  Optional[Any]			=				num_hidden_layers
											A_			:  Dict			=				num_attention_heads
											A_			:  Tuple			=				intermediate_size
											A_			:  Dict			=				hidden_act
											A_			:  List[Any]			=				hidden_dropout_prob
											A_			:  str			=				attention_probs_dropout_prob
											A_			:  Optional[Any]			=				initializer_range
											A_			:  List[str]			=				type_vocab_size
											A_			:  List[Any]			=				segment_means_seq_len
											A_			:  Dict			=				num_landmarks
											A_			:  int			=				conv_kernel_size
											A_			:  Optional[Any]			=				inv_coeff_init_option
											A_			:  str			=				layer_norm_eps
											super().__init__(pad_token_id=_lowerCamelCase				,			bos_token_id=_lowerCamelCase				,			eos_token_id=_lowerCamelCase				,			**_lowerCamelCase     )



