


"""simple docstring"""







def 					a__			(				SCREAMING_SNAKE_CASE    :    list[int]				):


  '''simple docstring'''







  if not nums:  # Makes sure that the list is not empty
    raise ValueError("List is empty"				)

  lowerCAmelCase     :     str								=							sum(SCREAMING_SNAKE_CASE				) / len(SCREAMING_SNAKE_CASE				)  # Calculate the average
  return sum(abs(x - average				) for x in nums				) / len(SCREAMING_SNAKE_CASE				)


if __name__ == "__main__":
     import doctest

     doctest.testmod()









"""simple docstring"""







import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation


class       SCREAMING_SNAKE_CASE__				(		unittest.TestCase				):
       """simple docstring"""


       def        lowercase__							(						self						):






         """simple docstring"""





         lowerCAmelCase     :     int								=							get_activation("swish"						)

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






         """simple docstring"""





         lowerCAmelCase     :     Union[str, Any]								=							get_activation("silu"						)

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






         """simple docstring"""





         lowerCAmelCase     :     Dict								=							get_activation("mish"						)

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






         """simple docstring"""





         lowerCAmelCase     :     Union[str, Any]								=							get_activation("gelu"						)

         self.assertIsInstance(snake_case__		,     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						)





