





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






						@slow
						def UpperCAmelCase_				(      self      :      int	)							->    Union[str, Any]:







							"""simple docstring"""


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

									snake_case_		:			str											=	FlaxAutoModel.from_pretrained(_A	)
									self.assertIsNotNone(_A	)
									self.assertIsInstance(_A		,   _A	)






						@slow
						def UpperCAmelCase_				(      self      :      int	)							->    Optional[int]:







							"""simple docstring"""


							for model_name in ["roberta-base", "roberta-large"]:
								with self.subTest(_A	):
									snake_case_		:			int											=	AutoConfig.from_pretrained(_A	)
									self.assertIsNotNone(_A	)
									self.assertIsInstance(_A		,   _A	)

									snake_case_		:			Tuple											=	FlaxAutoModel.from_pretrained(_A	)
									self.assertIsNotNone(_A	)
									self.assertIsInstance(_A		,   _A	)






						@slow
						def UpperCAmelCase_				(      self      :      Any	)							->    int:







							"""simple docstring"""


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

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

								eval(**_A	).block_until_ready()






						@slow
						def UpperCAmelCase_				(      self      :      Any	)							->    Any:







							"""simple docstring"""


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

								@jax.jit
								def eval(**_A      :      Optional[Any]	):
									return model(**_A	)

								eval(**_A	).block_until_ready()






						def UpperCAmelCase_				(      self      :      Optional[Any]	)							->    List[str]:







							"""simple docstring"""


							with self.assertRaisesRegex(
							    _A		,   'bert-base is not a local folder and is not a valid model identifier'	):
								snake_case_		:			Dict											=	FlaxAutoModel.from_pretrained('bert-base'	)






						def UpperCAmelCase_				(      self      :      Optional[int]	)							->    Optional[int]:







							"""simple docstring"""


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






						def UpperCAmelCase_				(      self      :      Optional[Any]	)							->    List[Any]:







							"""simple docstring"""


							with self.assertRaisesRegex(
							    _A		,   'hf-internal-testing/config-no-model does not appear to have a file named flax_model.msgpack'		,   ):
								snake_case_		:			Union[str, Any]											=	FlaxAutoModel.from_pretrained('hf-internal-testing/config-no-model'	)






						def UpperCAmelCase_				(      self      :      Optional[Any]	)							->    Union[str, Any]:







							"""simple docstring"""


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








import numpy as np


def 							SCREAMING_SNAKE_CASE__						(    __a   ):
	return (2 / (1 + np.exp(-2 * vector   ))) - 1


if __name__ == "__main__":
						import doctest

						doctest.testmod()

