




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




   def 							__magic_name__							(   self						:	Any				)				->							Union[str, Any]:




    '''simple docstring'''

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




   def 							__magic_name__							(   self						:	str				)				->							Dict:




    '''simple docstring'''

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

    A__	=    torch_builtin(snake_case_				)
    A__	=    geluaa(snake_case_				)

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

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




   def 							__magic_name__							(   self						:	List[str]				)				->							str:




    '''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(snake_case_				):
     get_activation("bogus"				)
    with self.assertRaises(snake_case_				):
     get_activation(snake_case_				)




   def 							__magic_name__							(   self						:	int				)				->							Tuple:




    '''simple docstring'''

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











"""simple docstring"""



SCREAMING_SNAKE_CASE    =	"\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n"

SCREAMING_SNAKE_CASE    =	[{"type": "code", "content": INSTALL_CONTENT}]
SCREAMING_SNAKE_CASE    =	{
    "{processor_class}": "FakeProcessorClass",
    "{model_class}": "FakeModelClass",
    "{object_class}": "FakeObjectClass",
}





