


import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation






class 	__lowercase					(	unittest.TestCase	):





      def 							_lowercase					(		self    :       Optional[int]							)     -> Optional[int]:






         """simple docstring"""







         UpperCAmelCase      					=  get_activation("""swish"""							)

         self.assertIsInstance(__lowerCamelCase       ,							nn.SiLU							)

         self.assertEqual(act(torch.tensor(-1_0_0       ,							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(2_0       ,							dtype=torch.floataa							)							).item()       ,							2_0							)





      def 							_lowercase					(		self    :       Any							)     -> str:






         """simple docstring"""







         UpperCAmelCase      					=  get_activation("""silu"""							)

         self.assertIsInstance(__lowerCamelCase       ,							nn.SiLU							)

         self.assertEqual(act(torch.tensor(-1_0_0       ,							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(2_0       ,							dtype=torch.floataa							)							).item()       ,							2_0							)





      def 							_lowercase					(		self    :       Dict							)     -> List[Any]:






         """simple docstring"""







         UpperCAmelCase      					=  get_activation("""mish"""							)

         self.assertIsInstance(__lowerCamelCase       ,							nn.Mish							)

         self.assertEqual(act(torch.tensor(-2_0_0       ,							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(2_0       ,							dtype=torch.floataa							)							).item()       ,							2_0							)





      def 							_lowercase					(		self    :       Optional[int]							)     -> Union[str, Any]:






         """simple docstring"""







         UpperCAmelCase      					=  get_activation("""gelu"""							)

         self.assertIsInstance(__lowerCamelCase       ,							nn.GELU							)

         self.assertEqual(act(torch.tensor(-1_0_0       ,							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(2_0       ,							dtype=torch.floataa							)							).item()       ,							2_0							)







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__a	 =      {
    """configuration_pegasus_x""": ["""PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PegasusXConfig"""],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __a	 =      [
     """PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """PegasusXForConditionalGeneration""",
     """PegasusXModel""",
     """PegasusXPreTrainedModel""",
 ]


if TYPE_CHECKING:
 from .configuration_pegasus_x import PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP, PegasusXConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_pegasus_x import (
      PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST,
      PegasusXForConditionalGeneration,
      PegasusXModel,
      PegasusXPreTrainedModel,
  )


else:
 import sys

 __a	 =      _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



