





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 _lowerCAmelCase (self      :Tuple					)->   List[Any]:
         __A			  =							tf.constant([-100, -1.0, -0.1, 0, 0.1, 1.0, 1_0_0.0]					)
         __A			  =							get_tf_activation('''gelu'''					)
         __A			  =							get_tf_activation('''gelu_10'''					)

         __A			  =							gelu(_SCREAMING_SNAKE_CASE					)
         __A			  =							geluaa(_SCREAMING_SNAKE_CASE					)

         __A			  =							tf.where(y_gelu_aa < 1_0.0       ,  1.0       ,  0.0					)

         self.assertEqual(tf.math.reduce_max(_SCREAMING_SNAKE_CASE					).numpy().item()       ,  1_0.0					)
         self.assertTrue(np.allclose(y_gelu * clipped_mask       ,  y_gelu_aa * clipped_mask					)					)






   def _lowerCAmelCase (self      :Any					)->   Dict:
         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(_SCREAMING_SNAKE_CASE					):
               get_tf_activation('''bogus'''					)
         with self.assertRaises(_SCREAMING_SNAKE_CASE					):
               get_tf_activation(_SCREAMING_SNAKE_CASE					)







'''simple docstring'''


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




		def 	_snake_case	(  self					:Tuple)					->			List[Any]:






								'''simple docstring'''






								UpperCamelCase_     :	List[str]					     =     tf.constant([-1_0_0, -1.0, -0.1, 0, 0.1, 1.0, 100.0])
								UpperCamelCase_     :	Any					     =     get_tf_activation("""gelu""")
								UpperCamelCase_     :	List[Any]					     =     get_tf_activation("""gelu_10""")

								UpperCamelCase_     :	Optional[int]					     =     gelu(_SCREAMING_SNAKE_CASE)
								UpperCamelCase_     :	Dict					     =     geluaa(_SCREAMING_SNAKE_CASE)

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

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





		def 	_snake_case	(  self					:Any)					->			Dict:






								'''simple docstring'''






								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(_SCREAMING_SNAKE_CASE):
														get_tf_activation("""bogus""")
								with self.assertRaises(_SCREAMING_SNAKE_CASE):
														get_tf_activation(_SCREAMING_SNAKE_CASE)




