
import unittest

from transformers import AutoTokenizer, is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow


if is_flax_available():
		import jax.numpy as jnp

		from transformers import FlaxXLMRobertaModel





@require_sentencepiece
@require_tokenizers
@require_flax
class       __A(				unittest.TestCase       ):

					@slow
					def    lowercase__      (	self					:     List[str]   ):
												lowerCamelCase_							  =					FlaxXLMRobertaModel.from_pretrained("""xlm-roberta-base"""   )
												lowerCamelCase_							  =					AutoTokenizer.from_pretrained("""xlm-roberta-base"""   )
												lowerCamelCase_							  =					"""The dog is cute and lives in the garden house"""
												lowerCamelCase_							  =					jnp.array([tokenizer.encode(__UpperCamelCase   )]   )

												lowerCamelCase_							  =					(1, 1_2, 7_6_8)  # batch_size, sequence_length, embedding_vector_dim
												lowerCamelCase_							  =					jnp.array(
												    [[-0.0101, 0.1218, -0.0803, 0.0801, 0.1327, 0.0776, -0.1215, 0.2383, 0.3338, 0.3106, 0.0300, 0.0252]]   )

												lowerCamelCase_							  =					model(__UpperCamelCase   )["""last_hidden_state"""]
												self.assertEqual(output.shape   ,					__UpperCamelCase   )
												# compare the actual values for a slice of last dim
												self.assertTrue(jnp.allclose(output[:, :, -1]   ,					__UpperCamelCase   ,					atol=1E-3   )   )







from ..utils import DummyObject, requires_backends





class       __A(				metaclass=UpperCAmelCase       ):
					SCREAMING_SNAKE_CASE			    =    ['''torch''', '''scipy''']

					def __init__(	self					:     Any   ,					*__UpperCamelCase					:     str   ,					**__UpperCamelCase					:     Any   ):
												requires_backends(self   ,					["""torch""", """scipy"""]   )

					@classmethod
					def    lowercase__      (	cls					:     Dict   ,					*__UpperCamelCase					:     str   ,					**__UpperCamelCase					:     Dict   ):
												requires_backends(cls   ,					["""torch""", """scipy"""]   )



					@classmethod
					def    lowercase__      (	cls					:     str   ,					*__UpperCamelCase					:     Optional[int]   ,					**__UpperCamelCase					:     Optional[int]   ):
												requires_backends(cls   ,					["""torch""", """scipy"""]   )





