'''simple docstring'''






def    __UpperCAmelCase			(  a_:       str							):
   _UpperCAmelCase							:	Optional[int]							=   [0 for i in range(len(lowerCAmelCase__							)							)]

   # initialize interval's left pointer and right pointer
   _UpperCAmelCase							,       _UpperCAmelCase							:	Union[str, Any]							=   0, 0

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

      while go_next(lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__							):
         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:
         _UpperCAmelCase							,       _UpperCAmelCase							:	Union[str, Any]							=   i, i + z_result[i] - 1

   return z_result






def    __UpperCAmelCase			(  a_:       int,					a_:       list[int],					a_:       str							):
   return i + z_result[i] < len(lowerCAmelCase__							) and s[z_result[i]] == s[i + z_result[i]]






def    __UpperCAmelCase			(  a_:       str,					a_:       str							):
   _UpperCAmelCase							:	int							=   0
   # concatenate 'pattern' and 'input_str' and call z_function
   # with concatenated string
   _UpperCAmelCase							:	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(lowerCAmelCase__							):
         answer += 1

   return answer


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 					__lowerCAmelCase					(   unittest.TestCase       ):


		'''simple docstring'''



		def 			__UpperCAmelCase       (  self      ):
				__a           =			get_activation('''swish'''      )

				self.assertIsInstance(_a							, 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 			__UpperCAmelCase       (  self      ):
				__a           =			get_activation('''silu'''      )

				self.assertIsInstance(_a							, 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 			__UpperCAmelCase       (  self      ):
				__a           =			get_activation('''mish'''      )

				self.assertIsInstance(_a							, 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 			__UpperCAmelCase       (  self      ):
				__a           =			get_activation('''gelu'''      )

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






