


import unittest

import numpy as np

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

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
				from transformers.models.bert.modeling_flax_bert import (
				    FlaxBertForMaskedLM,
				    FlaxBertForMultipleChoice,
				    FlaxBertForNextSentencePrediction,
				    FlaxBertForPreTraining,
				    FlaxBertForQuestionAnswering,
				    FlaxBertForSequenceClassification,
				    FlaxBertForTokenClassification,
				    FlaxBertModel,
				)






class    _UpperCamelCase     (       unittest.TestCase					):

				"""simple docstring"""







				def __init__(    self					, a__					, a__=13					, a__=7					, a__=True					, a__=True					, a__=True					, a__=True					, a__=99					, a__=32					, a__=5					, a__=4					, a__=37					, a__="gelu"					, a__=0.1					, a__=0.1					, a__=512					, a__=16					, a__=2					, a__=0.02					, a__=4					, )						->					Union[str, Any]:
					A             =					parent
					A             =					batch_size
					A             =					seq_length
					A             =					is_training
					A             =					use_attention_mask
					A             =					use_token_type_ids
					A             =					use_labels
					A             =					vocab_size
					A             =					hidden_size
					A             =					num_hidden_layers
					A             =					num_attention_heads
					A             =					intermediate_size
					A             =					hidden_act
					A             =					hidden_dropout_prob
					A             =					attention_probs_dropout_prob
					A             =					max_position_embeddings
					A             =					type_vocab_size
					A             =					type_sequence_label_size
					A             =					initializer_range
					A             =					num_choices

				def   _UpperCAmelCase       (    self )						->					List[Any]:
					A             =					ids_tensor([self.batch_size, self.seq_length]					, self.vocab_size )

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

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

					A             =					BertConfig(
					    vocab_size=self.vocab_size					, hidden_size=self.hidden_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					, is_decoder=a__					, initializer_range=self.initializer_range					, )

					return config, input_ids, token_type_ids, attention_mask

				def   _UpperCAmelCase       (    self )						->					Optional[Any]:
					A             =					self.prepare_config_and_inputs()
					A       ,      A       ,      A       ,      A             =					config_and_inputs
					A             =					{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": attention_mask}
					return config, inputs_dict

				def   _UpperCAmelCase       (    self )						->					str:
					A             =					self.prepare_config_and_inputs()
					A       ,      A       ,      A       ,      A             =					config_and_inputs

					A             =					True
					A             =					floats_tensor([self.batch_size, self.seq_length, self.hidden_size] )
					A             =					ids_tensor([self.batch_size, self.seq_length]					, vocab_size=2 )

					return (
					    config,
					    input_ids,
					    attention_mask,
					    encoder_hidden_states,
					    encoder_attention_mask,
					)






@require_flax
class    _UpperCamelCase     (       __snake_case     ,		unittest.TestCase					):

				"""simple docstring"""







				lowerCAmelCase					=			True

				lowerCAmelCase					=			(
				    (
				        FlaxBertModel,
				        FlaxBertForPreTraining,
				        FlaxBertForMaskedLM,
				        FlaxBertForMultipleChoice,
				        FlaxBertForQuestionAnswering,
				        FlaxBertForNextSentencePrediction,
				        FlaxBertForSequenceClassification,
				        FlaxBertForTokenClassification,
				        FlaxBertForQuestionAnswering,
				    )
				    if is_flax_available()
				    else ()
				)

				def   _UpperCAmelCase       (    self )						->					Optional[int]:
					A             =					FlaxBertModelTester(self )

				@slow
				def   _UpperCAmelCase       (    self )						->					int:
					# Only check this for base model, not necessary for all model classes.
					# This will also help speed-up tests.
					A             =					FlaxBertModel.from_pretrained("""bert-base-cased""" )
					A             =					model(np.ones((1, 1) ) )
					self.assertIsNotNone(a__ )







from typing import List

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


_lowercase							:   Any						=						logging.get_logger(__name__)

_lowercase							:   Union[str, Any]						=						{
    "snap-research/efficientformer-l1-300": (
        "https://huggingface.co/snap-research/efficientformer-l1-300/resolve/main/config.json"
    ),
}






class    _UpperCamelCase     (       __snake_case					):

				"""simple docstring"""







				lowerCAmelCase					=			'efficientformer'

				def __init__(    self					, a__ = [3, 2, 6, 4]					, a__ = [48, 96, 224, 448]					, a__ = [True, True, True, True]					, a__ = 448					, a__ = 32					, a__ = 4					, a__ = 7					, a__ = 5					, a__ = 8					, a__ = 4					, a__ = 0.0					, a__ = 16					, a__ = 3					, a__ = 3					, a__ = 3					, a__ = 2					, a__ = 1					, a__ = 0.0					, a__ = 1					, a__ = True					, a__ = True					, a__ = 1e-5					, a__ = "gelu"					, a__ = 0.02					, a__ = 1e-12					, a__ = 224					, a__ = 1e-05					, **a__					, )						->					None:
					super().__init__(**a__ )

					A             =					hidden_act
					A             =					hidden_dropout_prob
					A             =					hidden_sizes
					A             =					num_hidden_layers
					A             =					num_attention_heads
					A             =					initializer_range
					A             =					layer_norm_eps
					A             =					patch_size
					A             =					num_channels
					A             =					depths
					A             =					mlp_expansion_ratio
					A             =					downsamples
					A             =					dim
					A             =					key_dim
					A             =					attention_ratio
					A             =					resolution
					A             =					pool_size
					A             =					downsample_patch_size
					A             =					downsample_stride
					A             =					downsample_pad
					A             =					drop_path_rate
					A             =					num_metaad_blocks
					A             =					distillation
					A             =					use_layer_scale
					A             =					layer_scale_init_value
					A             =					image_size
					A             =					batch_norm_eps



