



"""simple docstring"""







import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation







class       UpperCamelCase__   (	unittest.TestCase  ):




      """simple docstring"""




      def      SCREAMING_SNAKE_CASE__ (      self				:      Union[str, Any]       ):
        lowerCAmelCase_   :				Optional[int]								= get_activation('swish'       )

        self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,			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      SCREAMING_SNAKE_CASE__ (      self				:      Tuple       ):
        lowerCAmelCase_   :				Optional[Any]								= get_activation('silu'       )

        self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,			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      SCREAMING_SNAKE_CASE__ (      self				:      int       ):
        lowerCAmelCase_   :				Any								= get_activation('mish'       )

        self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,			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      SCREAMING_SNAKE_CASE__ (      self				:      List[Any]       ):
        lowerCAmelCase_   :				Tuple								= get_activation('gelu'       )

        self.assertIsInstance(SCREAMING_SNAKE_CASE_    ,			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"""







import re

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str						)						->   list:

  """simple docstring"""




  return [char.split() for char in re.split(R'[^ a-z A-Z 0-9 \s]'    ,   str_						)]

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str						)						->   str:

  """simple docstring"""




  lowerCAmelCase_   :				str								= split_input(str_						)
  return "".join(
      [''.join([char.capitalize() for char in sub_str]						) for sub_str in string_split]						)

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str    ,   lowerCAmelCase__      :				bool    ,   lowerCAmelCase__      :				str						)						->   str:

  """simple docstring"""




  try:
    lowerCAmelCase_   :				int								= split_input(lowerCAmelCase__						)
    if upper:
      lowerCAmelCase_   :				Optional[int]								= ''.join(
          [
              separator.join([char.upper() for char in sub_str]						)
              for sub_str in string_split
          ]						)
    else:
      lowerCAmelCase_   :				Any								= ''.join(
          [
              separator.join([char.lower() for char in sub_str]						)
              for sub_str in string_split
          ]						)
    return res_str
  except IndexError:
    return "not valid string"

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str						)						->   str:

  """simple docstring"""




  return to_simple_case(lowerCAmelCase__						)

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str						)						->   str:

  """simple docstring"""




  try:
    lowerCAmelCase_   :				Dict								= to_simple_case(lowerCAmelCase__						)
    return res_str[0].lower() + res_str[1:]
  except IndexError:
    return "not valid string"

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str    ,   lowerCAmelCase__      :				bool						)						->   str:

  """simple docstring"""




  return to_complex_case(lowerCAmelCase__    ,   lowerCAmelCase__    ,   '_'						)

def 				UpperCamelCase_    (    lowerCAmelCase__      :				str    ,   lowerCAmelCase__      :				bool						)						->   str:

  """simple docstring"""




  return to_complex_case(lowerCAmelCase__    ,   lowerCAmelCase__    ,   '-'						)


if __name__ == "__main__":
     __import__("""doctest""").testmod()





