





from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow


if is_tf_available():
  import numpy as np
  import tensorflow as tf

  from transformers import TFXLMRobertaModel







@require_tf
@require_sentencepiece
@require_tokenizers
class 	__lowerCAmelCase      (       unittest.TestCase	):





   @slow
   def 						_snake_case			(			self   )					->	Optional[Any]:
      """simple docstring"""





      a__						:    List[Any]   		=	TFXLMRobertaModel.from_pretrained("jplu/tf-xlm-roberta-base"   )

      a__						:    Any   		=	{
          "input_ids": tf.convert_to_tensor([[0, 2_646, 10_269, 83, 99_942, 2]]       ,      dtype=tf.intaa   ),  # "My dog is cute"
          "attention_mask": tf.convert_to_tensor([[1, 1, 1, 1, 1, 1]]       ,      dtype=tf.intaa   ),
      }

      a__						:    List[Any]   		=	model(snake_case   )["last_hidden_state"]
      a__						:    Dict   		=	tf.TensorShape((1, 6, 768)   )
      self.assertEqual(output.shape       ,      snake_case   )
      # compare the actual values for a slice.
      a__						:    Any   		=	tf.convert_to_tensor(
          [
              [
                  [0.0_681_762, 0.10_894_451, 0.06_772_504],
                  [-0.06_423_668, 0.02_366_615, 0.04_329_344],
                  [-0.06_057_295, 0.09_974_135, -0.00_070_584],
              ]
          ]       ,      dtype=tf.floataa       ,      )

      self.assertTrue(np.allclose(output[:, :3, :3].numpy()       ,      expected_slice.numpy()       ,      atol=1E-4   )   )








from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
  if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_torch_and_transformers_objects import (
      VersatileDiffusionDualGuidedPipeline,
      VersatileDiffusionImageVariationPipeline,
      VersatileDiffusionPipeline,
      VersatileDiffusionTextToImagePipeline,
  )
else:
  from .modeling_text_unet import UNetFlatConditionModel
  from .pipeline_versatile_diffusion import VersatileDiffusionPipeline
  from .pipeline_versatile_diffusion_dual_guided import VersatileDiffusionDualGuidedPipeline
  from .pipeline_versatile_diffusion_image_variation import VersatileDiffusionImageVariationPipeline
  from .pipeline_versatile_diffusion_text_to_image import VersatileDiffusionTextToImagePipeline

