"""simple docstring"""







import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation



class  _lowerCamelCase			(unittest.TestCase     ):







				def 							__UpperCAmelCase					( self    :       Optional[Any]						):

					"""simple docstring"""






					_lowercase :    str							=							get_activation('swish'						)

					self.assertIsInstance(lowerCamelCase_			,					nn.SiLU						)

					self.assertEqual(act(torch.tensor(-1_0_0			,					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(2_0			,					dtype=torch.floataa						)						).item()			,					2_0						)







				def 							__UpperCAmelCase					( self    :       Any						):

					"""simple docstring"""






					_lowercase :    List[str]							=							get_activation('silu'						)

					self.assertIsInstance(lowerCamelCase_			,					nn.SiLU						)

					self.assertEqual(act(torch.tensor(-1_0_0			,					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(2_0			,					dtype=torch.floataa						)						).item()			,					2_0						)







				def 							__UpperCAmelCase					( self    :       Optional[Any]						):

					"""simple docstring"""






					_lowercase :    Tuple							=							get_activation('mish'						)

					self.assertIsInstance(lowerCamelCase_			,					nn.Mish						)

					self.assertEqual(act(torch.tensor(-2_0_0			,					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(2_0			,					dtype=torch.floataa						)						).item()			,					2_0						)







				def 							__UpperCAmelCase					( self    :       int						):

					"""simple docstring"""






					_lowercase :    str							=							get_activation('gelu'						)

					self.assertIsInstance(lowerCamelCase_			,					nn.GELU						)

					self.assertEqual(act(torch.tensor(-1_0_0			,					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(2_0			,					dtype=torch.floataa						)						).item()			,					2_0						)




"""simple docstring"""







def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    str							=							[0 for i in range(len(__UpperCAmelCase			)			)]

	# initialize interval's left pointer and right pointer
	_lowercase				,      _lowercase :    str							=							0, 0

	for i in range(1     ,len(__UpperCAmelCase			)			):
		# case when current index is inside the interval
		if i <= right_pointer:
			_lowercase :    Union[str, Any]							=							min(right_pointer - i + 1     ,z_result[i - left_pointer]			)
			_lowercase :    Any							=							min_edge

		while go_next(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):
			z_result[i] += 1

		# if new index's result gives us more right interval,
		# we've to update left_pointer and right_pointer
		if i + z_result[i] - 1 > right_pointer:
			_lowercase				,      _lowercase :    Optional[int]							=							i, i + z_result[i] - 1

	return z_result


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	return i + z_result[i] < len(__UpperCAmelCase			) and s[z_result[i]] == s[i + z_result[i]]


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Union[str, Any]							=							0
	# concatenate 'pattern' and 'input_str' and call z_function
	# with concatenated string
	_lowercase :    List[str]							=							z_function(pattern + input_str			)

	for val in z_result:
		# if value is greater then length of the pattern string
		# that means this index is starting position of substring
		# which is equal to pattern string
		if val >= len(__UpperCAmelCase			):
			answer += 1

	return answer


if __name__ == "__main__":
						import doctest

						doctest.testmod()



