

import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation






class      lowerCamelCase_      (	unittest.TestCase	):




	def        lowerCAmelCase_       (     self						:     Optional[int]							):
		__A :			str		    =			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        lowerCAmelCase_       (     self						:     Optional[int]							):
		__A :			List[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        lowerCAmelCase_       (     self						:     Tuple							):
		__A :			Optional[int]		    =			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        lowerCAmelCase_       (     self						:     int							):
		__A :			int		    =			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'''



from .testing import (
    are_the_same_tensors,
    execute_subprocess_async,
    require_bnb,
    require_cpu,
    require_cuda,
    require_huggingface_suite,
    require_mps,
    require_multi_gpu,
    require_multi_xpu,
    require_safetensors,
    require_single_gpu,
    require_single_xpu,
    require_torch_min_version,
    require_tpu,
    require_xpu,
    skip,
    slow,
)
from .training import RegressionDataset, RegressionModel, RegressionModelaXPU


from .scripts import test_script, test_sync, test_ops  # isort: skip
