






"""simple docstring"""
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


_lowerCAmelCase         =	re.compile(r"^(?P<major>\d+)" r"\.(?P<minor>\d+)" r"\.(?P<patch>\d+)$")



@total_ordering
@dataclass
class      SCREAMING_SNAKE_CASE  :





	"""simple docstring"""




	_A       :				str
	_A       :				Optional[str]    =				None
	_A       :				Optional[Union[str, int]]    =				None
	_A       :				Optional[Union[str, int]]    =				None
	_A       :				Optional[Union[str, int]]    =				None





	def    lowerCamelCase(self							):
		A_		:						Union[str, Any]	    =   _str_to_version_tuple(self.version_str							)





	def __repr__(self							):
		return f"""{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}"""





	@property
	def    lowerCamelCase(self							):
		return self.major, self.minor, self.patch





	def    lowerCamelCase(self     ,     lowerCAmelCase_							):
		if isinstance(lowerCAmelCase_     ,     lowerCAmelCase_							):
			return Version(lowerCAmelCase_							)
		elif isinstance(lowerCAmelCase_     ,     lowerCAmelCase_							):
			return other
		raise TypeError(f"""{other} (type {type(lowerCAmelCase_							)}) cannot be compared to version."""							)





	def __eq__(self     ,     lowerCAmelCase_							):
		try:
			A_		:						Optional[Any]	    =   self._validate_operand(lowerCAmelCase_							)
		except (TypeError, ValueError):
			return False
		else:
			return self.tuple == other.tuple





	def __lt__(self     ,     lowerCAmelCase_							):
		A_		:						Tuple	    =   self._validate_operand(lowerCAmelCase_							)
		return self.tuple < other.tuple





	def __hash__(self							):
		return hash(_version_tuple_to_str(self.tuple							)							)





	@classmethod
	def    lowerCamelCase(cls     ,     lowerCAmelCase_							):
		A_		:						Union[str, Any]	    =   {f.name for f in dataclasses.fields(cls							)}
		return cls(**{k: v for k, v in dic.items() if k in field_names}							)





	def    lowerCamelCase(self							):
		return self.version_str






def 			__UpperCamelCase	(		snake_case__					):
	A_		:						Any	    =   _VERSION_REG.match(snake_case__					)
	if not res:
		raise ValueError(F"""Invalid version '{version_str}'. Format should be x.y.z with {{x,y,z}} being digits."""					)
	return tuple(int(snake_case__					) for v in [res.group("""major"""					), res.group("""minor"""					), res.group("""patch"""					)]					)






def 			__UpperCamelCase	(		snake_case__					):
	return ".".join(str(snake_case__					) for v in version_tuple					)









"""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    lowerCamelCase(self							):
		A_		:						Optional[int]	    =   get_activation("""swish"""							)

		self.assertIsInstance(lowerCAmelCase_     ,     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							):
		A_		:						Dict	    =   get_activation("""silu"""							)

		self.assertIsInstance(lowerCAmelCase_     ,     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							):
		A_		:						Optional[Any]	    =   get_activation("""mish"""							)

		self.assertIsInstance(lowerCAmelCase_     ,     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							):
		A_		:						int	    =   get_activation("""gelu"""							)

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

