


import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation


class      __lowerCAmelCase  (			unittest.TestCase       ):






  """simple docstring"""





  def        lowerCAmelCase__	(  self							:							List[Any]	) ->			int:




     """simple docstring"""
     snake_case_            =       get_activation("swish"	)

     self.assertIsInstance(_lowerCAmelCase     ,					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        lowerCAmelCase__	(  self							:							Optional[Any]	) ->			Any:




     """simple docstring"""
     snake_case_            =       get_activation("silu"	)

     self.assertIsInstance(_lowerCAmelCase     ,					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        lowerCAmelCase__	(  self							:							List[str]	) ->			List[Any]:




     """simple docstring"""
     snake_case_            =       get_activation("mish"	)

     self.assertIsInstance(_lowerCAmelCase     ,					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        lowerCAmelCase__	(  self							:							Tuple	) ->			Optional[int]:




     """simple docstring"""
     snake_case_            =       get_activation("gelu"	)

     self.assertIsInstance(_lowerCAmelCase     ,					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       _lowerCAmelCase    (				lowerCAmelCase_				:List[str]		,    lowerCAmelCase_				:int				)->Optional[int]:
   '''simple docstring'''






   snake_case_            =       0
   while b > 0:
      if b & 1:
         res += a

      a += a
      b >>= 1

   return res



def       _lowerCAmelCase    (				lowerCAmelCase_				:int		,    lowerCAmelCase_				:List[str]		,    lowerCAmelCase_				:Dict				)->Dict:
   '''simple docstring'''






   snake_case_            =       0
   while b > 0:
      if b & 1:
         snake_case_            =       ((res % c) + (a % c)) % c

      a += a
      b >>= 1

   return res




