





import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation




class 			__UpperCamelCase    (							unittest.TestCase    ):





     def 		UpperCamelCase(     self					):
        _UpperCAmelCase           =   get_activation('''swish'''					)

        self.assertIsInstance(_UpperCamelCase				,							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					):
        _UpperCAmelCase           =   get_activation('''silu'''					)

        self.assertIsInstance(_UpperCamelCase				,							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					):
        _UpperCAmelCase           =   get_activation('''mish'''					)

        self.assertIsInstance(_UpperCamelCase				,							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					):
        _UpperCAmelCase           =   get_activation('''gelu'''					)

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






import baseaa
def      A__       (    SCREAMING_SNAKE_CASE_   :      str						)  ->  bytes:






   """simple docstring"""







   return baseaa.baaencode(string.encode('''utf-8'''						)						)
def      A__       (    SCREAMING_SNAKE_CASE_   :      bytes						)  ->  str:






   """simple docstring"""







   return baseaa.baadecode(SCREAMING_SNAKE_CASE_						).decode('''utf-8'''						)


if __name__ == "__main__":
   UpperCAmelCase_           =	"Hello World!"
   UpperCAmelCase_           =	baseaa_encode(test)
   print(encoded)

   UpperCAmelCase_           =	baseaa_decode(encoded)
   print(decoded)