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




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



     """simple docstring"""






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




   def      __a						(   self      :    List[str]				):



     """simple docstring"""






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

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

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

     SCREAMING_SNAKE_CASE__      							=				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=_lowercase	,     initializer_range=self.initializer_range	,     )

     return config, input_ids, token_type_ids, attention_mask




   def      __a						(   self      :    Optional[int]				):



     """simple docstring"""






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




   def      __a						(   self      :    Any				):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__      							=				self.prepare_config_and_inputs()
     SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__      							=				config_and_inputs

     SCREAMING_SNAKE_CASE__      							=				True
     SCREAMING_SNAKE_CASE__      							=				floats_tensor([self.batch_size, self.seq_length, self.hidden_size]				)
     SCREAMING_SNAKE_CASE__      							=				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 __snake_case    (						lowerCamelCase_       ,		unittest.TestCase		):
   lowerCAmelCase_														=							True

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




   def      __a						(   self      :    List[str]				):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__      							=				FlaxBertModelTester(self				)




   @slow
   def      __a						(   self      :    str				):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__      							=				FlaxBertModel.from_pretrained("""bert-base-cased"""				)
     SCREAMING_SNAKE_CASE__      							=				model(np.ones((1, 1)				)				)
     self.assertIsNotNone(_lowercase				)

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__lowerCamelCase      :			Optional[Any]							       =		{
    '''configuration_efficientformer''': [
        '''EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''EfficientFormerConfig''',
    ]
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase      :			Dict							       =		['''EfficientFormerImageProcessor''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase      :			Optional[int]							       =		[
       '''EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''EfficientFormerForImageClassification''',
       '''EfficientFormerForImageClassificationWithTeacher''',
       '''EfficientFormerModel''',
       '''EfficientFormerPreTrainedModel''',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase      :			Any							       =		[
       '''TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''TFEfficientFormerForImageClassification''',
       '''TFEfficientFormerForImageClassificationWithTeacher''',
       '''TFEfficientFormerModel''',
       '''TFEfficientFormerPreTrainedModel''',
   ]

if TYPE_CHECKING:
   from .configuration_efficientformer import EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, EfficientFormerConfig

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_efficientformer import EfficientFormerImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_efficientformer import (
          EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          EfficientFormerForImageClassification,
          EfficientFormerForImageClassificationWithTeacher,
          EfficientFormerModel,
          EfficientFormerPreTrainedModel,
      )
   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_efficientformer import (
          TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFEfficientFormerForImageClassification,
          TFEfficientFormerForImageClassificationWithTeacher,
          TFEfficientFormerModel,
          TFEfficientFormerPreTrainedModel,
      )

else:
   import sys

   __lowerCamelCase      :			List[Any]							       =		_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
