

import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation







class        a__       (   unittest.TestCase       ):







  """simple docstring"""




  def  _lowercase      (			self    : str		)					->int:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      str       =   get_activation("""swish"""		)

        self.assertIsInstance(UpperCAmelCase__				,				nn.SiLU		)

        self.assertEqual(act(torch.tensor(-1_0_0				,				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(2_0				,				dtype=torch.floataa		)		).item()				,				2_0		)


  def  _lowercase      (			self    : List[Any]		)					->List[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[Any]       =   get_activation("""silu"""		)

        self.assertIsInstance(UpperCAmelCase__				,				nn.SiLU		)

        self.assertEqual(act(torch.tensor(-1_0_0				,				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(2_0				,				dtype=torch.floataa		)		).item()				,				2_0		)


  def  _lowercase      (			self    : Optional[int]		)					->str:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Dict       =   get_activation("""mish"""		)

        self.assertIsInstance(UpperCAmelCase__				,				nn.Mish		)

        self.assertEqual(act(torch.tensor(-2_0_0				,				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(2_0				,				dtype=torch.floataa		)		).item()				,				2_0		)




  def  _lowercase      (			self    : Optional[int]		)					->Any:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      str       =   get_activation("""gelu"""		)

        self.assertIsInstance(UpperCAmelCase__				,				nn.GELU		)

        self.assertEqual(act(torch.tensor(-1_0_0				,				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(2_0				,				dtype=torch.floataa		)		).item()				,				2_0		)







def 					__lowercase      (     _A						,    _A			)     ->						int:
      return int((input_a, input_a).count(1			) != 0			)






def 					__lowercase      (     )     ->						None:
      assert or_gate(0						,    0			) == 0
      assert or_gate(0						,    1			) == 1
      assert or_gate(1						,    0			) == 1
      assert or_gate(1						,    1			) == 1


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




