


"""simple docstring"""




import os


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_doctest_list.py
lowercase_			     =  "."


if __name__ == "__main__":
				lowercase_			     =  os.path.join(REPO_PATH, "utils/documentation_tests.txt")
				lowercase_			     =  []
				lowercase_			     =  []
				with open(doctest_file_path) as fp:
								for line in fp:
												lowercase_			     =  line.strip()
												lowercase_			     =  os.path.join(REPO_PATH, line)
												if not (os.path.isfile(path) or os.path.isdir(path)):
																non_existent_paths.append(line)
												all_paths.append(path)
				if len(non_existent_paths) > 0:
								lowercase_			     =  "\n".join(non_existent_paths)
								raise ValueError(F'''`utils/documentation_tests.txt` contains non-existent paths:\n{non_existent_paths}''')
				if all_paths != sorted(all_paths):
								raise ValueError("Files in `utils/documentation_tests.txt` are not in alphabetical order.")










"""simple docstring"""




import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation
class 					__lowerCAmelCase					(   unittest.TestCase       ):


		'''simple docstring'''



		def 			__UpperCAmelCase       (  self      ):
				__a           =			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      ):
				__a           =			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      ):
				__a           =			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      ):
				__a           =			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      )






