




'''simple docstring'''

import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
						import torch

						from transformers.activations import gelu_new, gelu_python, get_activation



@require_torch
class 		SCREAMING_SNAKE_CASE__  (			unittest.TestCase	):





			def 							A (      self						:    Dict							):



						"""simple docstring"""




						__snake_case			=		torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]							)
						__snake_case			=		get_activation("gelu"							)
						self.assertTrue(torch.allclose(gelu_python(a_							)      ,		torch_builtin(a_							)							)							)
						self.assertFalse(torch.allclose(gelu_python(a_							)      ,		gelu_new(a_							)							)							)





			def 							A (      self						:    List[Any]							):



						"""simple docstring"""




						__snake_case			=		torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]							)
						__snake_case			=		get_activation("gelu"							)
						__snake_case			=		get_activation("gelu_10"							)

						__snake_case			=		torch_builtin(a_							)
						__snake_case			=		geluaa(a_							)

						__snake_case			=		torch.where(y_gelu_aa < 10.0      ,		1      ,		0							)

						self.assertTrue(torch.max(a_							).item() == 10.0							)
						self.assertTrue(torch.allclose(y_gelu * clipped_mask      ,		y_gelu_aa * clipped_mask							)							)





			def 							A (      self						:    Tuple							):



						"""simple docstring"""




						get_activation("gelu"							)
						get_activation("gelu_10"							)
						get_activation("gelu_fast"							)
						get_activation("gelu_new"							)
						get_activation("gelu_python"							)
						get_activation("gelu_pytorch_tanh"							)
						get_activation("linear"							)
						get_activation("mish"							)
						get_activation("quick_gelu"							)
						get_activation("relu"							)
						get_activation("sigmoid"							)
						get_activation("silu"							)
						get_activation("swish"							)
						get_activation("tanh"							)
						with self.assertRaises(a_							):
									get_activation("bogus"							)
						with self.assertRaises(a_							):
									get_activation(a_							)






			def 							A (      self						:    str							):



						"""simple docstring"""




						__snake_case			=		get_activation("gelu"							)
						__snake_case			=		1
						__snake_case			=		get_activation("gelu"							)
						self.assertEqual(acta.a      ,		1							)
						with self.assertRaises(a_							):
									__snake_case			=		acta.a











def lowerCamelCase__  (     _lowercase					,		_lowercase ):

     '''simple docstring'''


     while a != 0:
          UpperCAmelCase_,       UpperCAmelCase_     :				Optional[int]  =     b % a, a
     return b







def lowerCamelCase__  (     _lowercase					,		_lowercase ):

     '''simple docstring'''


     if gcd(_lowercase					,		_lowercase ) != 1:
          UpperCAmelCase_     :				int  =     f'''mod inverse of {a!r} and {m!r} does not exist'''
          raise ValueError(_lowercase )
     UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_     :				Union[str, Any]  =     1, 0, a
     UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_     :				Dict  =     0, 1, m
     while va != 0:
          UpperCAmelCase_     :				List[Any]  =     ua // va
          UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_,       UpperCAmelCase_     :				Any  =     (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
     return ua % m