


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

   '''simple docstring'''







   @slow
   def   _snake_case    (  self  : Tuple							):






         '''simple docstring'''



         for model_name in ["bert-base-cased", "bert-large-uncased"]:
               with self.subTest(_lowerCamelCase							):
                     __lowerCamelCase     :      List[Any]       						=						AutoConfig.from_pretrained(_lowerCamelCase							)
                     self.assertIsNotNone(_lowerCamelCase							)
                     self.assertIsInstance(_lowerCamelCase       ,  _lowerCamelCase							)

                     __lowerCamelCase     :      Dict       						=						FlaxAutoModel.from_pretrained(_lowerCamelCase							)
                     self.assertIsNotNone(_lowerCamelCase							)
                     self.assertIsInstance(_lowerCamelCase       ,  _lowerCamelCase							)

   @slow
   def   _snake_case    (  self  : Optional[int]							):






         '''simple docstring'''



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

                     __lowerCamelCase     :      List[Any]       						=						FlaxAutoModel.from_pretrained(_lowerCamelCase							)
                     self.assertIsNotNone(_lowerCamelCase							)
                     self.assertIsInstance(_lowerCamelCase       ,  _lowerCamelCase							)

   @slow
   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         for model_name in ["bert-base-cased", "bert-large-uncased"]:
               __lowerCamelCase     :      Dict       						=						AutoTokenizer.from_pretrained(_lowerCamelCase							)
               __lowerCamelCase     :      Any       						=						FlaxBertModel.from_pretrained(_lowerCamelCase							)
               __lowerCamelCase     :      Tuple       						=						tokenizer("""Do you support jax jitted function?"""       ,  return_tensors=TensorType.JAX							)

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

               eval(**_lowerCamelCase							).block_until_ready()

   @slow
   def   _snake_case    (  self  : List[str]							):






         '''simple docstring'''



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

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

               eval(**_lowerCamelCase							).block_until_ready()

   def   _snake_case    (  self  : int							):






         '''simple docstring'''



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

   def   _snake_case    (  self  : str							):






         '''simple docstring'''



         with self.assertRaisesRegex(
             _lowerCamelCase       ,  R"""aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"""							):
               __lowerCamelCase     :      Optional[Any]       						=						FlaxAutoModel.from_pretrained(_lowerCamelCase       ,  revision="""aaaaaa"""							)

   def   _snake_case    (  self  : Optional[Any]							):






         '''simple docstring'''



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


   def   _snake_case    (  self  : Optional[int]							):






         '''simple docstring'''



         with self.assertRaisesRegex(_lowerCamelCase       ,  """Use `from_pt=True` to load this model"""							):
               __lowerCamelCase     :      Optional[int]       						=						FlaxAutoModel.from_pretrained("""hf-internal-testing/tiny-bert-pt-only"""							)







def   _UpperCAmelCase       (     UpperCAmelCase      :			str      ):
      """simple docstring"""




      __lowerCamelCase     :      List[Any]       						=						hex_num.strip()
      if not hex_num:
            raise ValueError("""No value was passed to the function"""      )

      __lowerCamelCase     :      Dict       						=						hex_num[0] == """-"""
      if is_negative:
            __lowerCamelCase     :      Optional[Any]       						=						hex_num[1:]

      try:
            __lowerCamelCase     :      Any       						=						int(UpperCAmelCase						,	16      )
      except ValueError:
            raise ValueError("""Invalid value was passed to the function"""      )

      __lowerCamelCase     :      List[str]       						=						""""""
      while int_num > 0:
            __lowerCamelCase     :      Dict       						=						str(int_num % 2      ) + bin_str
            int_num >>= 1

      return int(("""-""" + bin_str) if is_negative else bin_str      )


if __name__ == "__main__":
    import doctest

    doctest.testmod()



