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






     """simple docstring"""







     @slow
     def  UpperCAmelCase__							(				self							:							List[Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Tuple					=		TFXLMRobertaModel.from_pretrained('''jplu/tf-xlm-roberta-base''' )

       __SCREAMING_SNAKE_CASE      :	int					=		{
           '''input_ids''': tf.convert_to_tensor([[0, 2646, 1_0269, 83, 9_9942, 2]]     ,						dtype=tf.intaa ),  # "My dog is cute"
           '''attention_mask''': tf.convert_to_tensor([[1, 1, 1, 1, 1, 1]]     ,						dtype=tf.intaa ),
       }

       __SCREAMING_SNAKE_CASE      :	Any					=		model(_A )['''last_hidden_state''']
       __SCREAMING_SNAKE_CASE      :	Dict					=		tf.TensorShape((1, 6, 768) )
       self.assertEqual(output.shape     ,						_A )
       # compare the actual values for a slice.
       __SCREAMING_SNAKE_CASE      :	Dict					=		tf.convert_to_tensor(
           [
               [
                   [0.0_68_17_62, 0.10_89_44_51, 0.06_77_25_04],
                   [-0.06_42_36_68, 0.02_36_66_15, 0.04_32_93_44],
                   [-0.06_05_72_95, 0.09_97_41_35, -0.00_07_05_84],
               ]
           ]     ,						dtype=tf.floataa     ,						)

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



from __future__ import annotations







def 							_lowerCamelCase   (			SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE = None		,				SCREAMING_SNAKE_CASE = None   ):
      '''simple docstring'''







      if start is None:
            A_							       =		0

      if end is None:
            A_							       =		len(SCREAMING_SNAKE_CASE   ) - 1

      if start >= end:
            return

      A_							       =		(start + end) // 2

      slowsort(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE   )
      slowsort(SCREAMING_SNAKE_CASE		,				mid + 1		,				SCREAMING_SNAKE_CASE   )

      if sequence[end] < sequence[mid]:
            A_       ,A_							       =		sequence[mid], sequence[end]

      slowsort(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				end - 1   )


if __name__ == "__main__":
      from doctest import testmod

      testmod()





