"""simple docstring"""






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







            """simple docstring"""



            lowercase														=			FlaxXLMRobertaModel.from_pretrained("""xlm-roberta-base"""		)
            lowercase														=			AutoTokenizer.from_pretrained("""xlm-roberta-base"""		)
            lowercase														=			"""The dog is cute and lives in the garden house"""
            lowercase														=			jnp.array([tokenizer.encode(__UpperCamelCase		)]		)

            lowercase														=			(1, 12, 768)  # batch_size, sequence_length, embedding_vector_dim
            lowercase														=			jnp.array(
                [[-0.0_1_0_1, 0.1_2_1_8, -0.0_8_0_3, 0.0_8_0_1, 0.1_3_2_7, 0.0_7_7_6, -0.1_2_1_5, 0.2_3_8_3, 0.3_3_3_8, 0.3_1_0_6, 0.0_3_0_0, 0.0_2_5_2]]		)

            lowercase														=			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		)		)







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__lowerCAmelCase					: Dict        ={
    """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""],
    """tokenization_xlm""": ["""XLMTokenizer"""],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __lowerCAmelCase					: int        =[
           """XLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """XLMForMultipleChoice""",
           """XLMForQuestionAnswering""",
           """XLMForQuestionAnsweringSimple""",
           """XLMForSequenceClassification""",
           """XLMForTokenClassification""",
           """XLMModel""",
           """XLMPreTrainedModel""",
           """XLMWithLMHeadModel""",
       ]

try:
       if not is_tf_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __lowerCAmelCase					: Union[str, Any]        =[
           """TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """TFXLMForMultipleChoice""",
           """TFXLMForQuestionAnsweringSimple""",
           """TFXLMForSequenceClassification""",
           """TFXLMForTokenClassification""",
           """TFXLMMainLayer""",
           """TFXLMModel""",
           """TFXLMPreTrainedModel""",
           """TFXLMWithLMHeadModel""",
       ]


if TYPE_CHECKING:
       from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
       from .tokenization_xlm import XLMTokenizer

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_xlm import (
                  XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
                  XLMForMultipleChoice,
                  XLMForQuestionAnswering,
                  XLMForQuestionAnsweringSimple,
                  XLMForSequenceClassification,
                  XLMForTokenClassification,
                  XLMModel,
                  XLMPreTrainedModel,
                  XLMWithLMHeadModel,
              )

       try:
              if not is_tf_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_tf_xlm import (
                  TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
                  TFXLMForMultipleChoice,
                  TFXLMForQuestionAnsweringSimple,
                  TFXLMForSequenceClassification,
                  TFXLMForTokenClassification,
                  TFXLMMainLayer,
                  TFXLMModel,
                  TFXLMPreTrainedModel,
                  TFXLMWithLMHeadModel,
              )

else:
       import sys

       __lowerCAmelCase					: Optional[int]        =_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



