



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




			'''simple docstring'''






			def 			snake_case__					(       self							:			Dict			):
					'''simple docstring'''





					__UpperCAmelCase   :					Union[str, Any]													=     tf.constant([-1_00, -1.0, -0.1, 0, 0.1, 1.0, 1_0_0.0]			)
					__UpperCAmelCase   :					Any													=     get_tf_activation('''gelu'''			)
					__UpperCAmelCase   :					Union[str, Any]													=     get_tf_activation('''gelu_10'''			)

					__UpperCAmelCase   :					int													=     gelu(UpperCamelCase__			)
					__UpperCAmelCase   :					int													=     geluaa(UpperCamelCase__			)

					__UpperCAmelCase   :					int													=     tf.where(y_gelu_aa < 1_0.0	,	1.0	,	0.0			)

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




			def 			snake_case__					(       self							:			Optional[int]			):
					'''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(UpperCamelCase__			):
							get_tf_activation('''bogus'''			)
					with self.assertRaises(UpperCamelCase__			):
							get_tf_activation(UpperCamelCase__			)








def 	a						(				_UpperCAmelCase							: str						):







		'''simple docstring'''





		__UpperCAmelCase   :					Optional[Any]													=     53_81
		for x in s:
				__UpperCAmelCase   :					str													=     ((hash_value << 5) + hash_value) + ord(_UpperCAmelCase						)
		return hash_value & 0xFFFF_FFFF





