


'''simple docstring'''

import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation


class 					a__ (       unittest.TestCase					):







				"""simple docstring"""



				def     _snake_case     (self						):
										__lowerCAmelCase											= get_activation('''swish'''						)

										self.assertIsInstance(_a				,	nn.SiLU						)

										self.assertEqual(act(torch.tensor(-1_00				,	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     _snake_case     (self						):
										__lowerCAmelCase											= get_activation('''silu'''						)

										self.assertIsInstance(_a				,	nn.SiLU						)

										self.assertEqual(act(torch.tensor(-1_00				,	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     _snake_case     (self						):
										__lowerCAmelCase											= get_activation('''mish'''						)

										self.assertIsInstance(_a				,	nn.Mish						)

										self.assertEqual(act(torch.tensor(-2_00				,	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     _snake_case     (self						):
										__lowerCAmelCase											= get_activation('''gelu'''						)

										self.assertIsInstance(_a				,	nn.GELU						)

										self.assertEqual(act(torch.tensor(-1_00				,	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"""




def        lowercase							(		lowerCAmelCase__ :     list			) ->      bool:
		if not isinstance(lowerCAmelCase__    ,					lowerCAmelCase__			):
				raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''			)
		if len(lowerCAmelCase__			) == 0:
				raise ValueError('''Input list must be a non empty list'''			)
		if len(lowerCAmelCase__			) == 1:
				return True
		__a           =			series[1] - series[0]
		for index in range(len(lowerCAmelCase__			) - 1			):
				if series[index + 1] - series[index] != common_diff:
						return False
		return True

def        lowercase							(		lowerCAmelCase__ :     list			) ->      float:
		if not isinstance(lowerCAmelCase__    ,					lowerCAmelCase__			):
				raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''			)
		if len(lowerCAmelCase__			) == 0:
				raise ValueError('''Input list must be a non empty list'''			)
		__a           =			0
		for val in series:
				answer += val
		return answer / len(lowerCAmelCase__			)


if __name__ == "__main__":
				import doctest

				doctest.testmod()






