



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		,							_snake_case		,							_snake_case=13		,							_snake_case=7		,							_snake_case=True		,							_snake_case=True		,							_snake_case=True		,							_snake_case=True		,							_snake_case=99		,							_snake_case=24		,							_snake_case=32		,							_snake_case=5		,							_snake_case=4		,							_snake_case=37		,							_snake_case="gelu"		,							_snake_case=0.1		,							_snake_case=0.1		,							_snake_case=512		,							_snake_case=16		,							_snake_case=2		,							_snake_case=0.02		,							_snake_case=4		,							):



									"""simple docstring"""





									_lowerCAmelCase         =       parent
									_lowerCAmelCase         =       batch_size
									_lowerCAmelCase         =       seq_length
									_lowerCAmelCase         =       is_training
									_lowerCAmelCase         =       use_attention_mask
									_lowerCAmelCase         =       use_token_type_ids
									_lowerCAmelCase         =       use_labels
									_lowerCAmelCase         =       vocab_size
									_lowerCAmelCase         =       hidden_size
									_lowerCAmelCase         =       embedding_size
									_lowerCAmelCase         =       num_hidden_layers
									_lowerCAmelCase         =       num_attention_heads
									_lowerCAmelCase         =       intermediate_size
									_lowerCAmelCase         =       hidden_act
									_lowerCAmelCase         =       hidden_dropout_prob
									_lowerCAmelCase         =       attention_probs_dropout_prob
									_lowerCAmelCase         =       max_position_embeddings
									_lowerCAmelCase         =       type_vocab_size
									_lowerCAmelCase         =       type_sequence_label_size
									_lowerCAmelCase         =       initializer_range
									_lowerCAmelCase         =       num_choices




				def 				snake_case  (				self						):



									"""simple docstring"""





									_lowerCAmelCase         =       ids_tensor([self.batch_size, self.seq_length]		,							self.vocab_size						)

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

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

									_lowerCAmelCase         =       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						):



									"""simple docstring"""





									_lowerCAmelCase         =       self.prepare_config_and_inputs()
									_lowerCAmelCase      ,      _lowerCAmelCase      ,      _lowerCAmelCase      ,      _lowerCAmelCase         =       config_and_inputs
									_lowerCAmelCase         =       {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": attention_mask}
									return config, inputs_dict





@require_flax
class    __lowerCAmelCase					(	lowerCamelCase__			,		unittest.TestCase			):
				__lowerCamelCase					=							True

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




				def 				snake_case  (				self						):



									"""simple docstring"""





									_lowerCAmelCase         =       FlaxElectraModelTester(self						)




				@slow
				def 				snake_case  (				self						):



									"""simple docstring"""





									for model_class_name in self.all_model_classes:
														if model_class_name == FlaxElectraForMaskedLM:
																			_lowerCAmelCase         =       model_class_name.from_pretrained("""google/electra-small-generator"""						)
														else:
																			_lowerCAmelCase         =       model_class_name.from_pretrained("""google/electra-small-discriminator"""						)
														_lowerCAmelCase         =       model(np.ones((1, 1)						)						)
														self.assertIsNotNone(_snake_case						)








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


A__       =			logging.get_logger(__name__)

A__       =			{
    """MCG-NJU/videomae-base""": """https://huggingface.co/MCG-NJU/videomae-base/resolve/main/config.json""",
}





class    __lowerCAmelCase					(	lowerCamelCase__			):
				__lowerCamelCase					=							'''videomae'''




				def __init__(				self		,							_snake_case=224		,							_snake_case=16		,							_snake_case=3		,							_snake_case=16		,							_snake_case=2		,							_snake_case=768		,							_snake_case=12		,							_snake_case=12		,							_snake_case=3072		,							_snake_case="gelu"		,							_snake_case=0.0		,							_snake_case=0.0		,							_snake_case=0.02		,							_snake_case=1e-12		,							_snake_case=True		,							_snake_case=True		,							_snake_case=6		,							_snake_case=384		,							_snake_case=4		,							_snake_case=1536		,							_snake_case=True		,							**_snake_case		,							):



									"""simple docstring"""





									super().__init__(**_snake_case						)

									_lowerCAmelCase         =       image_size
									_lowerCAmelCase         =       patch_size
									_lowerCAmelCase         =       num_channels
									_lowerCAmelCase         =       num_frames
									_lowerCAmelCase         =       tubelet_size

									_lowerCAmelCase         =       hidden_size
									_lowerCAmelCase         =       num_hidden_layers
									_lowerCAmelCase         =       num_attention_heads
									_lowerCAmelCase         =       intermediate_size
									_lowerCAmelCase         =       hidden_act
									_lowerCAmelCase         =       hidden_dropout_prob
									_lowerCAmelCase         =       attention_probs_dropout_prob
									_lowerCAmelCase         =       initializer_range
									_lowerCAmelCase         =       layer_norm_eps
									_lowerCAmelCase         =       qkv_bias
									_lowerCAmelCase         =       use_mean_pooling

									_lowerCAmelCase         =       decoder_num_attention_heads
									_lowerCAmelCase         =       decoder_hidden_size
									_lowerCAmelCase         =       decoder_num_hidden_layers
									_lowerCAmelCase         =       decoder_intermediate_size
									_lowerCAmelCase         =       norm_pix_loss



