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

      @slow
      def 							A__			(		self		):







            """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 							A__			(		self		):







            """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 							A__			(		self		):







            """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 							A__			(		self		):







            """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 							A__			(		self		):







            """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 							A__			(		self		):







            """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 							A__			(		self		):







            """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 							A__			(		self		):







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




"""simple docstring"""






from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Features, Sequence, Value
from .base import TaskTemplate





@dataclass(frozen=lowerCAmelCase      )
class 					_A		(			lowerCAmelCase      ):
      # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
      snake_case__     :  str				    =      field(default='question-answering-extractive'    ,       metadata={'include_in_asdict_even_if_is_default': True}      )
      snake_case__     :  ClassVar[Features]				    =      Features({'question': Value('string'      ), 'context': Value('string'      )}      )
      snake_case__     :  ClassVar[Features]				    =      Features(
          {
              'answers': Sequence(
                  {
                      'text': Value('string'      ),
                      'answer_start': Value('int32'      ),
                  }      )
          }      )
      snake_case__     :  str				    =      "question"
      snake_case__     :  str				    =      "context"
      snake_case__     :  str				    =      "answers"

      @property
      def 							A__			(		self		):







            """simple docstring"""



            return {self.question_column: "question", self.context_column: "context", self.answers_column: "answers"}



