



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

    @slow
    def 					_UpperCAmelCase	(				self			:				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 					_UpperCAmelCase	(				self			:				Union[str, Any]):







      """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 					_UpperCAmelCase	(				self			:				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_			:				List[Any]):
          return model(**lowerCAmelCase_)

        eval(**lowerCAmelCase_).block_until_ready()

    @slow
    def 					_UpperCAmelCase	(				self			:				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_			:				Optional[int]):
          return model(**lowerCAmelCase_)

        eval(**lowerCAmelCase_).block_until_ready()

    def 					_UpperCAmelCase	(				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 					_UpperCAmelCase	(				self			:				List[str]):







      """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 					_UpperCAmelCase	(				self			:				Optional[int]):







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







      """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"""
def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase							) ->						list[list[int]]:







  '''simple docstring'''


  lowercase_								= []
  if len(__lowerCAmelCase							) == 1:
    return [nums.copy()]
  for _ in range(len(__lowerCAmelCase							)							):
    lowercase_								= nums.pop(0							)
    lowercase_								= permute(__lowerCAmelCase							)
    for perm in permutations:
      perm.append(__lowerCAmelCase							)
    result.extend(__lowerCAmelCase							)
    nums.append(__lowerCAmelCase							)
  return result


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase							) ->						Tuple:







  '''simple docstring'''


  def backtrack(__lowerCAmelCase							):
    if start == len(__lowerCAmelCase							) - 1:
      output.append(nums[:]							)
    else:
      for i in range(__lowerCAmelCase ,  len(__lowerCAmelCase							)							):
        lowercase_					,    lowercase_								= nums[i], nums[start]
        backtrack(start + 1							)
        lowercase_					,    lowercase_								= nums[i], nums[start]  # backtrack

  lowercase_								= []
  backtrack(0							)
  return output


if __name__ == "__main__":
       import doctest

       # use res to print the data in permute2 function
       UpperCAmelCase						:		Optional[Any]			= permutea([1, 2, 3])
       print(res)
       doctest.testmod()

