



import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation
class 				__A					( unittest.TestCase      ):





			def        _snake_case    (self				):
						lowerCamelCase__ :      List[Any]								=		get_activation("""swish"""				)

						self.assertIsInstance(_lowerCAmelCase							,    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        _snake_case    (self				):
						lowerCamelCase__ :      List[str]								=		get_activation("""silu"""				)

						self.assertIsInstance(_lowerCAmelCase							,    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        _snake_case    (self				):
						lowerCamelCase__ :      int								=		get_activation("""mish"""				)

						self.assertIsInstance(_lowerCAmelCase							,    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        _snake_case    (self				):
						lowerCamelCase__ :      Dict								=		get_activation("""gelu"""				)

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



			'''simple docstring'''







			lowerCamelCase__ :      int								=		[1]
			for i in range(2      ,			UpperCamelCase ):
						factorials.append(factorials[-1] * i )
			assert 0 <= k < factorials[-1] * n, "k out of bounds"

			lowerCamelCase__ :      Union[str, Any]								=		[]
			lowerCamelCase__ :      Optional[Any]								=		list(range(UpperCamelCase ) )

			# Find permutation
			while factorials:
						lowerCamelCase__ :      Union[str, Any]								=		factorials.pop()
						lowerCamelCase__							,lowerCamelCase__ :      Union[str, Any]								=		divmod(UpperCamelCase      ,			UpperCamelCase )
						permutation.append(elements[number] )
						elements.remove(elements[number] )
			permutation.append(elements[0] )

			return permutation


if __name__ == "__main__":
				import doctest

				doctest.testmod()



