





"""simple docstring"""






import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation





class       snake_case_       (    unittest.TestCase       ):



	"""simple docstring"""

	def       _UpperCAmelCase						(      self						):


					"""simple docstring"""

					A__							 =       get_activation('swish'						)

					self.assertIsInstance(_A  ,					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       _UpperCAmelCase						(      self						):


					"""simple docstring"""

					A__							 =       get_activation('silu'						)

					self.assertIsInstance(_A  ,					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       _UpperCAmelCase						(      self						):


					"""simple docstring"""

					A__							 =       get_activation('mish'						)

					self.assertIsInstance(_A  ,					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       _UpperCAmelCase						(      self						):


					"""simple docstring"""

					A__							 =       get_activation('gelu'						)

					self.assertIsInstance(_A  ,					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						)










"""simple docstring"""






import numpy as np



def  __lowerCamelCase					(					lowerCAmelCase__				):
				return 1 / (1 + np.exp(-vector				))



def  __lowerCamelCase					(					lowerCAmelCase__				):
				return vector * sigmoid(lowerCAmelCase__				)


if __name__ == "__main__":
					import doctest

					doctest.testmod()


