





'''simple docstring'''







from collections.abc import Iterable
from typing import Generic, TypeVar

snake_case_     :       Optional[Any]						=  TypeVar("_T")


class 					__a      (Generic[_T]     ):

							def __init__(							self							:     str       ,     __magic_name__							:     Iterable[_T] | None = None   )					->       Dict:







													"""simple docstring"""
													UpperCAmelCase_			:      list[_T]     						=  list(iterable or []   )
													UpperCAmelCase_			:      list[_T]     						=  []

							def __len__(							self							:     Optional[int]   )					->       List[Any]:







													"""simple docstring"""
													return len(self._stacka   ) + len(self._stacka   )

							def __repr__(							self							:     Optional[int]   )					->       List[str]:







													"""simple docstring"""
													return F"""Queue({tuple(self._stacka[::-1] + self._stacka   )})"""

							def     UpperCAmelCase__	(							self							:     List[Any]       ,     __magic_name__							:     _T   )					->       Optional[int]:







													"""simple docstring"""
													self._stacka.append(lowercase_   )



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







													"""simple docstring"""
													UpperCAmelCase_			:      Tuple     						=  self._stacka.pop
													UpperCAmelCase_			:      Tuple     						=  self._stacka.append

													if not self._stacka:
																			while self._stacka:
																									stacka_append(stacka_pop()   )

													if not self._stacka:
																			raise IndexError('''Queue is empty'''   )
													return self._stacka.pop()


if __name__ == "__main__":
						from doctest import testmod

						testmod()












'''simple docstring'''







import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation


class 					__a      (unittest.TestCase     ):

							def     UpperCAmelCase__	(							self							:     Dict   )					->       Dict:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  get_activation('''swish'''   )

													self.assertIsInstance(__magic_name__       ,     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     UpperCAmelCase__	(							self							:     Tuple   )					->       Tuple:







													"""simple docstring"""
													UpperCAmelCase_			:      Union[str, Any]     						=  get_activation('''silu'''   )

													self.assertIsInstance(__magic_name__       ,     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     UpperCAmelCase__	(							self							:     Tuple   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[int]     						=  get_activation('''mish'''   )

													self.assertIsInstance(__magic_name__       ,     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     UpperCAmelCase__	(							self							:     str   )					->       Optional[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[Any]     						=  get_activation('''gelu'''   )

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





