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

 '''simple docstring'''







 def        UpperCamelCase     (				self		:     Any   ):



   '''simple docstring'''




   UpperCAmelCase__			:				Optional[int]												=       tf.constant([-1_00, -1.0, -0.1, 0, 0.1, 1.0, 100.0]   )
   UpperCAmelCase__			:				Optional[Any]												=       get_tf_activation("gelu"   )
   UpperCAmelCase__			:				int												=       get_tf_activation("gelu_10"   )

   UpperCAmelCase__			:				Any												=       gelu(snake_case__   )
   UpperCAmelCase__			:				int												=       geluaa(snake_case__   )

   UpperCAmelCase__			:				int												=       tf.where(y_gelu_aa < 10.0 ,							1.0 ,							0.0   )

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







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





'''simple docstring'''





from math import cos, sin







def snake_case_    (				lowercase__		):
  UpperCAmelCase__			:				List[Any]												=       float(lowercase__		)
  return [[scaling_factor * int(x == y		) for x in range(2		)] for y in range(2		)]







def snake_case_    (				lowercase__		):
  UpperCAmelCase__					, UpperCAmelCase__			:				List[Any]												=       cos(lowercase__		), sin(lowercase__		)
  return [[c, -s], [s, c]]







def snake_case_    (				lowercase__		):
  UpperCAmelCase__					, UpperCAmelCase__			:				Dict												=       cos(lowercase__		), sin(lowercase__		)
  UpperCAmelCase__			:				Tuple												=       c * s
  return [[c * c, cs], [cs, s * s]]







def snake_case_    (				lowercase__		):
  UpperCAmelCase__					, UpperCAmelCase__			:				Dict												=       cos(lowercase__		), sin(lowercase__		)
  UpperCAmelCase__			:				Any												=       c * s
  return [[2 * c - 1, 2 * cs], [2 * cs, 2 * s - 1]]


print(F'    {scaling(5) = }')
print(F'  {rotation(4_5) = }')
print(F'{projection(4_5) = }')






print(F'{reflection(4_5) = }')



