



import unittest

import numpy as np

from transformers import is_tf_available
from transformers.testing_utils import require_tf


if is_tf_available():
		import tensorflow as tf

		from transformers.activations_tf import get_tf_activation






@require_tf
class 	_a			(      unittest.TestCase  ):






			def 							_snake_case   (    self )	->					List[Any]:
									lowerCAmelCase	:   Tuple					     =					tf.constant([-100, -1.0, -0.1, 0, 0.1, 1.0, 100.0] )
									lowerCAmelCase	:   Optional[Any]					     =					get_tf_activation("""gelu""" )
									lowerCAmelCase	:   Optional[Any]					     =					get_tf_activation("""gelu_10""" )

									lowerCAmelCase	:   List[Any]					     =					gelu(__lowerCamelCase )
									lowerCAmelCase	:   Dict					     =					geluaa(__lowerCamelCase )

									lowerCAmelCase	:   List[str]					     =					tf.where(y_gelu_aa < 10.0    ,  1.0    ,  0.0 )

									self.assertEqual(tf.math.reduce_max(__lowerCamelCase ).numpy().item()    ,  10.0 )
									self.assertTrue(np.allclose(y_gelu * clipped_mask    ,  y_gelu_aa * clipped_mask ) )






			def 							_snake_case   (    self )	->					Optional[Any]:
									get_tf_activation("""gelu""" )
									get_tf_activation("""gelu_10""" )
									get_tf_activation("""gelu_fast""" )
									get_tf_activation("""gelu_new""" )
									get_tf_activation("""glu""" )
									get_tf_activation("""mish""" )
									get_tf_activation("""quick_gelu""" )
									get_tf_activation("""relu""" )
									get_tf_activation("""sigmoid""" )
									get_tf_activation("""silu""" )
									get_tf_activation("""swish""" )
									get_tf_activation("""tanh""" )
									with self.assertRaises(__lowerCamelCase ):
															get_tf_activation("""bogus""" )
									with self.assertRaises(__lowerCamelCase ):
															get_tf_activation(__lowerCamelCase )









'''simple docstring'''





from ..utils import DummyObject, requires_backends
class 					lowercase							(				metaclass=_lowerCamelCase   ):


    '''simple docstring'''

    lowerCAmelCase__   					=				["torch", "transformers", "invisible_watermark"]

    def __init__(       self  :  Optional[Any]					,  *__lowerCamelCase  :  List[Any]					,  **__lowerCamelCase  :  Union[str, Any]  )				->				Dict:

     '''simple docstring'''




     requires_backends(self					,  ["torch", "transformers", "invisible_watermark"]  )

    @classmethod
    def  a__					(       cls  :  Any					,  *__lowerCamelCase  :  List[Any]					,  **__lowerCamelCase  :  Tuple  )				->				List[str]:

     '''simple docstring'''




     requires_backends(cls					,  ["torch", "transformers", "invisible_watermark"]  )




    @classmethod
    def  a__					(       cls  :  Union[str, Any]					,  *__lowerCamelCase  :  Tuple					,  **__lowerCamelCase  :  Tuple  )				->				List[Any]:

     '''simple docstring'''




     requires_backends(cls					,  ["torch", "transformers", "invisible_watermark"]  )
class 					lowercase							(				metaclass=_lowerCamelCase   ):


    '''simple docstring'''

    lowerCAmelCase__   					=				["torch", "transformers", "invisible_watermark"]

    def __init__(       self  :  Optional[Any]					,  *__lowerCamelCase  :  str					,  **__lowerCamelCase  :  Optional[Any]  )				->				str:

     '''simple docstring'''




     requires_backends(self					,  ["torch", "transformers", "invisible_watermark"]  )

    @classmethod
    def  a__					(       cls  :  Union[str, Any]					,  *__lowerCamelCase  :  List[str]					,  **__lowerCamelCase  :  Dict  )				->				Any:

     '''simple docstring'''




     requires_backends(cls					,  ["torch", "transformers", "invisible_watermark"]  )




    @classmethod
    def  a__					(       cls  :  List[Any]					,  *__lowerCamelCase  :  Union[str, Any]					,  **__lowerCamelCase  :  Any  )				->				Any:

     '''simple docstring'''




     requires_backends(cls					,  ["torch", "transformers", "invisible_watermark"]  )

