





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




											'''simple docstring'''


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

																							SCREAMING_SNAKE_CASE	=		FlaxAutoModel.from_pretrained(lowerCamelCase__ )
																							self.assertIsNotNone(lowerCamelCase__ )
																							self.assertIsInstance(lowerCamelCase__		,lowerCamelCase__ )






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




											'''simple docstring'''


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

																							SCREAMING_SNAKE_CASE	=		FlaxAutoModel.from_pretrained(lowerCamelCase__ )
																							self.assertIsNotNone(lowerCamelCase__ )
																							self.assertIsInstance(lowerCamelCase__		,lowerCamelCase__ )






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




											'''simple docstring'''


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

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

																	eval(**lowerCamelCase__ ).block_until_ready()






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




											'''simple docstring'''


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

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

																	eval(**lowerCamelCase__ ).block_until_ready()






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




											'''simple docstring'''


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






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




											'''simple docstring'''


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






					def        SCREAMING_SNAKE_CASE__						(							self		:					str )  ->	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"""		,):
																	SCREAMING_SNAKE_CASE	=		FlaxAutoModel.from_pretrained("""hf-internal-testing/config-no-model""" )






					def        SCREAMING_SNAKE_CASE__						(							self		:					Tuple )  ->	str:




											'''simple docstring'''


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









import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text



def      __lowercase     (   _SCREAMING_SNAKE_CASE			)				->     str:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE	=		[]
      for line in lines:
            SCREAMING_SNAKE_CASE	=		re.sub(r"""#.*"""				,		""""""				,		_SCREAMING_SNAKE_CASE			)  # remove comments
            if line:
                  filtered_lines.append(_SCREAMING_SNAKE_CASE			)
      SCREAMING_SNAKE_CASE	=		"""\n""".join(_SCREAMING_SNAKE_CASE			)

      # Make a hash from all this code
      SCREAMING_SNAKE_CASE	=		full_str.encode("""utf-8"""			)
      return shaaaa(_SCREAMING_SNAKE_CASE			).hexdigest()


# get importable module names and hash for caching
SCREAMING_SNAKE_CASE_		     = {
    """csv""": (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    """json""": (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    """pandas""": (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    """parquet""": (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    """arrow""": (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    """text""": (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    """imagefolder""": (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    """audiofolder""": (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
SCREAMING_SNAKE_CASE_		     = {
    """.csv""": ("""csv""", {}),
    """.tsv""": ("""csv""", {"""sep""": """\t"""}),
    """.json""": ("""json""", {}),
    """.jsonl""": ("""json""", {}),
    """.parquet""": ("""parquet""", {}),
    """.arrow""": ("""arrow""", {}),
    """.txt""": ("""text""", {}),
}
_EXTENSION_TO_MODULE.update({ext: ("""imagefolder""", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("""imagefolder""", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ("""audiofolder""", {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("""audiofolder""", {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
SCREAMING_SNAKE_CASE_		     = {"""imagefolder""", """audiofolder"""}

# Used to filter data files based on extensions given a module name
SCREAMING_SNAKE_CASE_		     = {}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
      _MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append(""".zip""")



_MODULE_TO_EXTENSIONS["audiofolder"].append(""".zip""")


