

import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation






class _UpperCamelCase							(							unittest.TestCase      ):
			'''simple docstring'''







			def 							__UpperCamelCase       (	self							:       List[str]		)							->				str:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE      :					List[Any]    =				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							:       int		)							->				Optional[int]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE      :					str    =				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							:       List[Any]		)							->				Any:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE      :					Any    =				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							:       Optional[Any]		)							->				Any:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE      :					Union[str, Any]    =				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"""




def 						UpperCAmelCase__		(     _UpperCAmelCase					):






  """simple docstring"""





  A_  :       List[str]										=  hex_num.strip()
  if not hex_num:
    raise ValueError('No value was passed to the function'					)

  A_  :       Any										=  hex_num[0] == '-'
  if is_negative:
    A_  :       Optional[Any]										=  hex_num[1:]

  try:
    A_  :       Tuple										=  int(_UpperCAmelCase ,					16					)
  except ValueError:
    raise ValueError('Invalid value was passed to the function'					)

  A_  :       Union[str, Any]										=  ''
  while int_num > 0:
    A_  :       Optional[Any]										=  str(int_num % 2					) + bin_str
    int_num >>= 1

  return int(('-' + bin_str) if is_negative else bin_str					)


if __name__ == "__main__":
   import doctest

   doctest.testmod()