






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				):






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

																								lowerCAmelCase__        =  FlaxAutoModel.from_pretrained(lowerCAmelCase__				)
																								self.assertIsNotNone(lowerCAmelCase__				)
																								self.assertIsInstance(lowerCAmelCase__       ,  lowerCAmelCase__				)






						@slow
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												for model_name in ["roberta-base", "roberta-large"]:
																		with self.subTest(lowerCAmelCase__				):
																								lowerCAmelCase__        =  AutoConfig.from_pretrained(lowerCAmelCase__				)
																								self.assertIsNotNone(lowerCAmelCase__				)
																								self.assertIsInstance(lowerCAmelCase__       ,  lowerCAmelCase__				)

																								lowerCAmelCase__        =  FlaxAutoModel.from_pretrained(lowerCAmelCase__				)
																								self.assertIsNotNone(lowerCAmelCase__				)
																								self.assertIsInstance(lowerCAmelCase__       ,  lowerCAmelCase__				)






						@slow
						def  UpperCamelCase__ (		self				):






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

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

																		eval(**lowerCAmelCase__				).block_until_ready()






						@slow
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												for model_name in ["roberta-base", "roberta-large"]:
																		lowerCAmelCase__        =  AutoTokenizer.from_pretrained(lowerCAmelCase__				)
																		lowerCAmelCase__        =  FlaxRobertaModel.from_pretrained(lowerCAmelCase__				)
																		lowerCAmelCase__        =  tokenizer('Do you support jax jitted function?'       ,  return_tensors=TensorType.JAX				)

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

																		eval(**lowerCAmelCase__				).block_until_ready()






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												with self.assertRaisesRegex(
												    lowerCAmelCase__       ,  'bert-base is not a local folder and is not a valid model identifier'				):
																		lowerCAmelCase__        =  FlaxAutoModel.from_pretrained('bert-base'				)






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												with self.assertRaisesRegex(
												    lowerCAmelCase__       ,  r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'				):
																		lowerCAmelCase__        =  FlaxAutoModel.from_pretrained(lowerCAmelCase__       ,  revision='aaaaaa'				)






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												with self.assertRaisesRegex(
												    lowerCAmelCase__       ,  'hf-internal-testing/config-no-model does not appear to have a file named flax_model.msgpack'       ,  ):
																		lowerCAmelCase__        =  FlaxAutoModel.from_pretrained('hf-internal-testing/config-no-model'				)







						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												with self.assertRaisesRegex(lowerCAmelCase__       ,  'Use `from_pt=True` to load this model'				):
																		lowerCAmelCase__        =  FlaxAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only'				)














def 		_UpperCamelCase				(      UpperCamelCase_    :   str						)					->				str:

						"""simple docstring"""



						return " ".join(input_str.split()[::-1]						)


if __name__ == "__main__":
					import doctest

					doctest.testmod()





