





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   __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=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					,			)				->  Union[str, Any]:
      """simple docstring"""





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





   def 	_snake_case ( self      )				->  Union[str, Any]:
      """simple docstring"""





      a__	:						int      		=  ids_tensor([self.batch_size, self.seq_length]					,			self.vocab_size      )

      a__	:						Optional[int]      		=  None
      if self.use_attention_mask:
         a__	:						Dict      		=  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__	:						List[Any]      		=  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=lowerCAmelCase_					,			initializer_range=self.initializer_range					,			)

      return config, input_ids, token_type_ids, attention_mask





   def 	_snake_case ( self      )				->  Dict:
      """simple docstring"""





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





   def 	_snake_case ( self      )				->  int:
      """simple docstring"""





      a__	:						Optional[int]      		=  self.prepare_config_and_inputs()
      a__		,     a__		,     a__		,     a__	:						Optional[int]      		=  config_and_inputs

      a__	:						List[str]      		=  True
      a__	:						Union[str, Any]      		=  floats_tensor([self.batch_size, self.seq_length, self.hidden_size]      )
      a__	:						List[str]      		=  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   __lowerCAmelCase			(					__a		,unittest.TestCase  ):
   _UpperCamelCase :						str     		=				True

   _UpperCamelCase :						str     		=				(
       (
           FlaxBertModel,
           FlaxBertForPreTraining,
           FlaxBertForMaskedLM,
           FlaxBertForMultipleChoice,
           FlaxBertForQuestionAnswering,
           FlaxBertForNextSentencePrediction,
           FlaxBertForSequenceClassification,
           FlaxBertForTokenClassification,
           FlaxBertForQuestionAnswering,
       )
       if is_flax_available()
       else ()
   )





   def 	_snake_case ( self      )				->  int:
      """simple docstring"""





      a__	:						Dict      		=  FlaxBertModelTester(self      )





   @slow
   def 	_snake_case ( self      )				->  Tuple:
      """simple docstring"""





      a__	:						Any      		=  FlaxBertModel.from_pretrained("bert-base-cased"      )
      a__	:						str      		=  model(np.ones((1, 1)      )      )
      self.assertIsNotNone(lowerCAmelCase_      )








from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


SCREAMING_SNAKE_CASE__       :			Dict			      =						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__       :			Any			      =						{
    """google/mobilenet_v2_1.4_224""": """https://huggingface.co/google/mobilenet_v2_1.4_224/resolve/main/config.json""",
    """google/mobilenet_v2_1.0_224""": """https://huggingface.co/google/mobilenet_v2_1.0_224/resolve/main/config.json""",
    """google/mobilenet_v2_0.75_160""": """https://huggingface.co/google/mobilenet_v2_0.75_160/resolve/main/config.json""",
    """google/mobilenet_v2_0.35_96""": """https://huggingface.co/google/mobilenet_v2_0.35_96/resolve/main/config.json""",
    # See all MobileNetV2 models at https://huggingface.co/models?filter=mobilenet_v2
}







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						Optional[int]     		=				"""mobilenet_v2"""





   def __init__( self					,			snake_case=3					,			snake_case=224					,			snake_case=1.0					,			snake_case=8					,			snake_case=8					,			snake_case=6					,			snake_case=32					,			snake_case=True					,			snake_case=True					,			snake_case="relu6"					,			snake_case=True					,			snake_case=0.8					,			snake_case=0.02					,			snake_case=0.001					,			snake_case=255					,			**snake_case					,			)				->  int:
      """simple docstring"""





      super().__init__(**snake_case      )

      if depth_multiplier <= 0:
         raise ValueError("depth_multiplier must be greater than zero."      )

      a__	:						str      		=  num_channels
      a__	:						Dict      		=  image_size
      a__	:						Any      		=  depth_multiplier
      a__	:						str      		=  depth_divisible_by
      a__	:						Optional[int]      		=  min_depth
      a__	:						Dict      		=  expand_ratio
      a__	:						str      		=  output_stride
      a__	:						Optional[int]      		=  first_layer_is_expansion
      a__	:						Union[str, Any]      		=  finegrained_output
      a__	:						Union[str, Any]      		=  hidden_act
      a__	:						str      		=  tf_padding
      a__	:						List[Any]      		=  classifier_dropout_prob
      a__	:						List[Any]      		=  initializer_range
      a__	:						Optional[Any]      		=  layer_norm_eps
      a__	:						str      		=  semantic_loss_ignore_index







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						Any     		=				version.parse("""1.11"""  )





   @property
   def 	_snake_case ( self      )				->  Mapping[str, Mapping[int, str]]:
      """simple docstring"""





      return OrderedDict([("pixel_values", {0: "batch"})]      )





   @property
   def 	_snake_case ( self      )				->  Mapping[str, Mapping[int, str]]:
      """simple docstring"""





      if self.task == "image-classification":
         return OrderedDict([("logits", {0: "batch"})]      )
      else:
         return OrderedDict([("last_hidden_state", {0: "batch"}), ("pooler_output", {0: "batch"})]      )





   @property
   def 	_snake_case ( self      )				->  float:
      """simple docstring"""





      return 1E-4

