




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




      """simple docstring"""





      @slow
      def      UpperCAmelCase				(				self     )		->    Optional[Any]:
         snake_case				:    Optional[int]           =	TFXLMRobertaModel.from_pretrained("""jplu/tf-xlm-roberta-base"""     )

         snake_case				:    List[Any]           =	{
             """input_ids""": tf.convert_to_tensor([[0, 2_6_4_6, 1_0_2_6_9, 8_3, 9_9_9_4_2, 2]]    ,				dtype=tf.intaa     ),  # "My dog is cute"
             """attention_mask""": tf.convert_to_tensor([[1, 1, 1, 1, 1, 1]]    ,				dtype=tf.intaa     ),
         }

         snake_case				:    Union[str, Any]           =	model(A     )["""last_hidden_state"""]
         snake_case				:    Any           =	tf.TensorShape((1, 6, 7_6_8)     )
         self.assertEqual(output.shape    ,				A     )
         # compare the actual values for a slice.
         snake_case				:    Optional[int]           =	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     )     )











def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase					)  ->       int:
   return int((input_a, input_a).count(1					) != 0					)




def 						SCREAMING_SNAKE_CASE__ (   )  ->       None:
   assert or_gate(0						,0					) == 0
   assert or_gate(0						,1					) == 1
   assert or_gate(1						,0					) == 1
   assert or_gate(1						,1					) == 1


if __name__ == "__main__":
       print(or_gate(0, 1))
       print(or_gate(1, 0))
       print(or_gate(0, 0))
       print(or_gate(1, 1))





