



import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation


class   snake_case_ (unittest.TestCase  ):




       """simple docstring"""






       def  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Optional[int]				      =		get_activation("swish")

             self.assertIsInstance(lowercase     ,nn.SiLU)

             self.assertEqual(act(torch.tensor(-100     ,dtype=torch.floataa)).item()     ,0)
             self.assertNotEqual(act(torch.tensor(-1     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(0     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(20     ,dtype=torch.floataa)).item()     ,20)



       def  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Optional[Any]				      =		get_activation("silu")

             self.assertIsInstance(lowercase     ,nn.SiLU)

             self.assertEqual(act(torch.tensor(-100     ,dtype=torch.floataa)).item()     ,0)
             self.assertNotEqual(act(torch.tensor(-1     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(0     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(20     ,dtype=torch.floataa)).item()     ,20)



       def  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Tuple				      =		get_activation("mish")

             self.assertIsInstance(lowercase     ,nn.Mish)

             self.assertEqual(act(torch.tensor(-200     ,dtype=torch.floataa)).item()     ,0)
             self.assertNotEqual(act(torch.tensor(-1     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(0     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(20     ,dtype=torch.floataa)).item()     ,20)



       def  A_   (     self):

             """simple docstring"""





             UpperCAmelCase_  :	Union[str, Any]				      =		get_activation("gelu")

             self.assertIsInstance(lowercase     ,nn.GELU)

             self.assertEqual(act(torch.tensor(-100     ,dtype=torch.floataa)).item()     ,0)
             self.assertNotEqual(act(torch.tensor(-1     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(0     ,dtype=torch.floataa)).item()     ,0)
             self.assertEqual(act(torch.tensor(20     ,dtype=torch.floataa)).item()     ,20)





def    _snake_case (       __snake_case					,  __snake_case    )     ->     int:






      '''simple docstring'''







      return int((input_a, input_a).count(0    ) != 0    )







def    _snake_case (       )     ->     None:






      '''simple docstring'''







      assert nand_gate(0					,  0    ) == 1
      assert nand_gate(0					,  1    ) == 1
      assert nand_gate(1					,  0    ) == 1
      assert nand_gate(1					,  1    ) == 0


if __name__ == "__main__":
   print(nand_gate(0, 0))
   print(nand_gate(0, 1))
   print(nand_gate(1, 0))
   print(nand_gate(1, 1))
