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 			_SCREAMING_SNAKE_CASE     (  self		)	->   Optional[Any]:

							'''simple docstring'''


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

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





			@slow
			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   int:

							'''simple docstring'''


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

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





			@slow
			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   List[Any]:

							'''simple docstring'''


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

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

											eval(**lowerCAmelCase__		).block_until_ready()





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

							'''simple docstring'''


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

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

											eval(**lowerCAmelCase__		).block_until_ready()





			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   Any:

							'''simple docstring'''


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





			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   List[Any]:

							'''simple docstring'''


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





			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   List[Any]:

							'''simple docstring'''


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





			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   str:

							'''simple docstring'''


							with self.assertRaisesRegex(lowerCAmelCase__ ,  '''Use `from_pt=True` to load this model'''		):
											__lowercase					     =				FlaxAutoModel.from_pretrained('''hf-internal-testing/tiny-bert-pt-only'''		)
from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a    :	List[Any]         =    logging.get_logger(__name__)

__a    :	List[Any]         =    {
    """MIT/ast-finetuned-audioset-10-10-0.4593""": (
        """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json"""
    ),
}




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			__a    :					Optional[Any]     					=		'''audio-spectrogram-transformer'''





			def __init__(  self ,  lowerCAmelCase__=7_68 ,  lowerCAmelCase__=12 ,  lowerCAmelCase__=12 ,  lowerCAmelCase__=30_72 ,  lowerCAmelCase__="gelu" ,  lowerCAmelCase__=0.0 ,  lowerCAmelCase__=0.0 ,  lowerCAmelCase__=0.02 ,  lowerCAmelCase__=1E-12 ,  lowerCAmelCase__=16 ,  lowerCAmelCase__=True ,  lowerCAmelCase__=10 ,  lowerCAmelCase__=10 ,  lowerCAmelCase__=10_24 ,  lowerCAmelCase__=1_28 ,  **lowerCAmelCase__ ,  )	->   Optional[Any]:

							'''simple docstring'''


							super().__init__(**lowerCAmelCase__		)

							__lowercase					     =				hidden_size
							__lowercase					     =				num_hidden_layers
							__lowercase					     =				num_attention_heads
							__lowercase					     =				intermediate_size
							__lowercase					     =				hidden_act
							__lowercase					     =				hidden_dropout_prob
							__lowercase					     =				attention_probs_dropout_prob
							__lowercase					     =				initializer_range
							__lowercase					     =				layer_norm_eps
							__lowercase					     =				patch_size
							__lowercase					     =				qkv_bias
							__lowercase					     =				frequency_stride
							__lowercase					     =				time_stride
							__lowercase					     =				max_length
							__lowercase					     =				num_mel_bins