




'''simple docstring'''



import unittest

from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow


if is_flax_available():
      import jax

      from transformers.models.auto.modeling_flax_auto import FlaxAutoModel
      from transformers.models.bert.modeling_flax_bert import FlaxBertModel
      from transformers.models.roberta.modeling_flax_roberta import FlaxRobertaModel






@require_flax
class 							_a				(			unittest.TestCase ):





       '''simple docstring'''






       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             for model_name in ["bert-base-cased", "bert-large-uncased"]:
                   with self.subTest(A  ):
                         SCREAMING_SNAKE_CASE   :      Dict    					=						AutoConfig.from_pretrained(A  )
                         self.assertIsNotNone(A  )
                         self.assertIsInstance(A,							A  )

                         SCREAMING_SNAKE_CASE   :      Tuple    					=						FlaxAutoModel.from_pretrained(A  )
                         self.assertIsNotNone(A  )
                         self.assertIsInstance(A,							A  )







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             for model_name in ["roberta-base", "roberta-large"]:
                   with self.subTest(A  ):
                         SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						AutoConfig.from_pretrained(A  )
                         self.assertIsNotNone(A  )
                         self.assertIsInstance(A,							A  )

                         SCREAMING_SNAKE_CASE   :      str    					=						FlaxAutoModel.from_pretrained(A  )
                         self.assertIsNotNone(A  )
                         self.assertIsInstance(A,							A  )







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             for model_name in ["bert-base-cased", "bert-large-uncased"]:
                   SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						AutoTokenizer.from_pretrained(A  )
                   SCREAMING_SNAKE_CASE   :      List[str]    					=						FlaxBertModel.from_pretrained(A  )
                   SCREAMING_SNAKE_CASE   :      List[str]    					=						tokenizer('Do you support jax jitted function?',							return_tensors=TensorType.JAX  )

                   @jax.jit
                   def eval(**A  ):
                         return model(**A  )

                   eval(**A  ).block_until_ready()







       @slow
       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             for model_name in ["roberta-base", "roberta-large"]:
                   SCREAMING_SNAKE_CASE   :      List[str]    					=						AutoTokenizer.from_pretrained(A  )
                   SCREAMING_SNAKE_CASE   :      int    					=						FlaxRobertaModel.from_pretrained(A  )
                   SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						tokenizer('Do you support jax jitted function?',							return_tensors=TensorType.JAX  )

                   @jax.jit
                   def eval(**A  ):
                         return model(**A  )

                   eval(**A  ).block_until_ready()







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             with self.assertRaisesRegex(
                 A,							'bert-base is not a local folder and is not a valid model identifier'  ):
                   SCREAMING_SNAKE_CASE   :      Optional[int]    					=						FlaxAutoModel.from_pretrained('bert-base'  )







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             with self.assertRaisesRegex(
                 A,							r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'  ):
                   SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						FlaxAutoModel.from_pretrained(A,							revision='aaaaaa'  )







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             with self.assertRaisesRegex(
                 A,							'hf-internal-testing/config-no-model does not appear to have a file named flax_model.msgpack',							):
                   SCREAMING_SNAKE_CASE   :      Optional[int]    					=						FlaxAutoModel.from_pretrained('hf-internal-testing/config-no-model'  )







       def        UpperCamelCase_							(      self  ):







             '''simple docstring'''







             with self.assertRaisesRegex(A,							'Use `from_pt=True` to load this model'  ):
                   SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						FlaxAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only'  )



'''simple docstring'''




from typing import TYPE_CHECKING

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


__UpperCAmelCase					={
    "configuration_mobilebert": [
        "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "MobileBertConfig",
        "MobileBertOnnxConfig",
    ],
    "tokenization_mobilebert": ["MobileBertTokenizer"],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase					=["MobileBertTokenizerFast"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase					=[
      "MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "MobileBertForMaskedLM",
      "MobileBertForMultipleChoice",
      "MobileBertForNextSentencePrediction",
      "MobileBertForPreTraining",
      "MobileBertForQuestionAnswering",
      "MobileBertForSequenceClassification",
      "MobileBertForTokenClassification",
      "MobileBertLayer",
      "MobileBertModel",
      "MobileBertPreTrainedModel",
      "load_tf_weights_in_mobilebert",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase					=[
      "TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFMobileBertForMaskedLM",
      "TFMobileBertForMultipleChoice",
      "TFMobileBertForNextSentencePrediction",
      "TFMobileBertForPreTraining",
      "TFMobileBertForQuestionAnswering",
      "TFMobileBertForSequenceClassification",
      "TFMobileBertForTokenClassification",
      "TFMobileBertMainLayer",
      "TFMobileBertModel",
      "TFMobileBertPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_mobilebert import (
      MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
      MobileBertConfig,
      MobileBertOnnxConfig,
  )
  from .tokenization_mobilebert import MobileBertTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_mobilebert_fast import MobileBertTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_mobilebert import (
        MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        MobileBertForMaskedLM,
        MobileBertForMultipleChoice,
        MobileBertForNextSentencePrediction,
        MobileBertForPreTraining,
        MobileBertForQuestionAnswering,
        MobileBertForSequenceClassification,
        MobileBertForTokenClassification,
        MobileBertLayer,
        MobileBertModel,
        MobileBertPreTrainedModel,
        load_tf_weights_in_mobilebert,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_mobilebert import (
        TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFMobileBertForMaskedLM,
        TFMobileBertForMultipleChoice,
        TFMobileBertForNextSentencePrediction,
        TFMobileBertForPreTraining,
        TFMobileBertForQuestionAnswering,
        TFMobileBertForSequenceClassification,
        TFMobileBertForTokenClassification,
        TFMobileBertMainLayer,
        TFMobileBertModel,
        TFMobileBertPreTrainedModel,
    )

else:
  import sys

  __UpperCAmelCase					=_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
