





import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation

class      A       (	unittest.TestCase						):



      def 	lowerCAmelCase__    (	self:						Any       )						->    List[str]:
         '''simple docstring'''

         UpperCAmelCase_											=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 	lowerCAmelCase__    (	self:						Union[str, Any]       )						->    List[Any]:
         '''simple docstring'''

         UpperCAmelCase_											=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 	lowerCAmelCase__    (	self:						Tuple       )						->    List[Any]:
         '''simple docstring'''

         UpperCAmelCase_											=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 	lowerCAmelCase__    (	self:						Tuple       )						->    List[Any]:
         '''simple docstring'''

         UpperCAmelCase_											=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       )











from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowercase  :   Any						      ={
    """configuration_upernet""": ["""UperNetConfig"""],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __lowercase  :   Tuple						      =[
         """UperNetForSemanticSegmentation""",
         """UperNetPreTrainedModel""",
     ]


if TYPE_CHECKING:
     from .configuration_upernet import UperNetConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_upernet import UperNetForSemanticSegmentation, UperNetPreTrainedModel


else:
     import sys

     __lowercase  :   Any						      =_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




