



"""simple docstring"""







import math

import tensorflow as tf
from packaging import version

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Tuple						)						->   Any:

  """simple docstring"""




  lowerCAmelCase_   :				Dict								= tf.convert_to_tensor(lowerCAmelCase__						)
  lowerCAmelCase_   :				Optional[Any]								= 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0						)    ,   x.dtype						)						))

  return x * cdf

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Any						)						->   Dict:

  """simple docstring"""




  lowerCAmelCase_   :				Tuple								= tf.convert_to_tensor(lowerCAmelCase__						)
  lowerCAmelCase_   :				Optional[int]								= tf.cast(math.pi    ,   x.dtype						)
  lowerCAmelCase_   :				List[str]								= tf.cast(0.044715    ,   x.dtype						)
  lowerCAmelCase_   :				Tuple								= 0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi						) * (x + coeff * tf.pow(lowerCAmelCase__    ,   3						))						))

  return x * cdf

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Optional[Any]						)						->   Tuple:

  """simple docstring"""




  lowerCAmelCase_   :				Union[str, Any]								= tf.convert_to_tensor(lowerCAmelCase__						)

  return x * tf.tanh(tf.math.softplus(lowerCAmelCase__						)						)

def 				UpperCamelCase_    (    lowerCAmelCase__      :				int						)						->   str:

  """simple docstring"""




  lowerCAmelCase_   :				Union[str, Any]								= tf.convert_to_tensor(lowerCAmelCase__						)
  lowerCAmelCase_   :				List[Any]								= tf.cast(0.044715    ,   x.dtype						)
  lowerCAmelCase_   :				str								= tf.cast(0.7978845608    ,   x.dtype						)

  return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)						))

def 				UpperCamelCase_    (    lowerCAmelCase__      :				List[Any]						)						->   int:

  """simple docstring"""




  lowerCAmelCase_   :				int								= tf.convert_to_tensor(lowerCAmelCase__						)
  lowerCAmelCase_   :				List[Any]								= tf.cast(1.702    ,   x.dtype						)
  return x * tf.math.sigmoid(coeff * x						)

def 				UpperCamelCase_    (    lowerCAmelCase__      :				int						)						->   Tuple:

  """simple docstring"""




  return tf.clip_by_value(_gelu(lowerCAmelCase__						)    ,   -10    ,   10						)

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Optional[Any]    ,   lowerCAmelCase__      :				Dict=-1						)						->   Any:

  """simple docstring"""




  lowerCAmelCase_						,lowerCAmelCase_   :				str								= tf.split(lowerCAmelCase__    ,   2    ,   axis=lowerCAmelCase__						)
  return a * tf.math.sigmoid(lowerCAmelCase__						)


if version.parse(tf.version.VERSION) >= version.parse("""2.4"""):

     def 				UpperCamelCase_    (    lowerCAmelCase__      :				str						)						->   str:

       """simple docstring"""




       return tf.keras.activations.gelu(lowerCAmelCase__    ,   approximate=lowerCAmelCase__						)

     lowercase__		:				Tuple          =	tf.keras.activations.gelu
     lowercase__		:				Optional[Any]          =	approximate_gelu_wrap
else:
     lowercase__		:				List[Any]          =	_gelu
     lowercase__		:				Optional[Any]          =	_gelu_new


lowercase__		:				Union[str, Any]          =	{
    """gelu""": gelu,
    """gelu_10""": gelu_aa,
    """gelu_fast""": gelu_fast,
    """gelu_new""": gelu_new,
    """glu""": glu,
    """mish""": mish,
    """quick_gelu""": quick_gelu,
    """relu""": tf.keras.activations.relu,
    """sigmoid""": tf.keras.activations.sigmoid,
    """silu""": tf.keras.activations.swish,
    """swish""": tf.keras.activations.swish,
    """tanh""": tf.keras.activations.tanh,
}

def 				UpperCamelCase_    (    lowerCAmelCase__      :				Tuple						)						->   Union[str, Any]:

  """simple docstring"""




  if activation_string in ACTaFN:
    return ACTaFN[activation_string]
  else:
    raise KeyError(f"function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys()						)}"						)










"""simple docstring"""







import warnings

from diffusers import StableDiffusionImgaImgPipeline  # noqa F401


warnings.warn(
    """The `image_to_image.py` script is outdated. Please use directly `from diffusers import"""
    """ StableDiffusionImg2ImgPipeline` instead."""
)





