'''simple docstring'''





import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation






class 				UpperCAmelCase (       unittest.TestCase ):




    '''simple docstring'''







    def       _UpperCamelCase    (       self )							-> int:
         SCREAMING_SNAKE_CASE					:			int    	=       get_activation('swish' )

         self.assertIsInstance(lowercase__    ,							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 )							-> Optional[Any]:
         SCREAMING_SNAKE_CASE					:			int    	=       get_activation('silu' )

         self.assertIsInstance(lowercase__    ,							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 )							-> str:
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       get_activation('mish' )

         self.assertIsInstance(lowercase__    ,							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 )							-> Union[str, Any]:
         SCREAMING_SNAKE_CASE					:			str    	=       get_activation('gelu' )

         self.assertIsInstance(lowercase__    ,							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     __lowerCAmelCase						(       a_       ,      a_		)      ->	str:





     '''simple docstring'''





     if number < 0 or shift_amount < 0:
          raise ValueError('both inputs must be positive integers'		)

     SCREAMING_SNAKE_CASE					:			str    	=       str(bin(a_		)		)
     binary_number += "0" * shift_amount
     return binary_number


def     __lowerCAmelCase						(       a_       ,      a_		)      ->	str:





     '''simple docstring'''





     if number < 0 or shift_amount < 0:
          raise ValueError('both inputs must be positive integers'		)

     SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       str(bin(a_		)		)[2:]
     if shift_amount >= len(a_		):
          return "0b0"
     SCREAMING_SNAKE_CASE					:			Dict    	=       binary_number[: len(a_		) - shift_amount]
     return "0b" + shifted_binary_number


def     __lowerCAmelCase						(       a_       ,      a_		)      ->	str:





     '''simple docstring'''





     if number >= 0:  # Get binary representation of positive number
          SCREAMING_SNAKE_CASE					:			Tuple    	=       '0' + str(bin(a_		)		).strip('-'		)[2:]
     else:  # Get binary (2's complement) representation of negative number
          SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       len(bin(a_		)[3:]		)  # Find 2's complement of number
          SCREAMING_SNAKE_CASE					:			Any    	=       bin(abs(a_		) - (1 << binary_number_length)		)[3:]
          SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       (
              '1' + '0' * (binary_number_length - len(a_		)) + binary_number
          )

     if shift_amount >= len(a_		):
          return "0b" + binary_number[0] * len(a_		)
     return (
         "0b"
         + binary_number[0] * shift_amount
         + binary_number[: len(a_		) - shift_amount]
     )


if __name__ == "__main__":
 import doctest

 doctest.testmod()



