



import math

import tensorflow as tf
from packaging import version



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			lowercase__   					=			tf.convert_to_tensor(SCREAMING_SNAKE_CASE_					)
			lowercase__   					=			0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0					)  ,					x.dtype					)					))

			return x * cdf



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			lowercase__   					=			tf.convert_to_tensor(SCREAMING_SNAKE_CASE_					)
			lowercase__   					=			tf.cast(math.pi  ,					x.dtype					)
			lowercase__   					=			tf.cast(0.04_4715  ,					x.dtype					)
			lowercase__   					=			0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi					) * (x + coeff * tf.pow(SCREAMING_SNAKE_CASE_  ,					3					))					))

			return x * cdf



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			lowercase__   					=			tf.convert_to_tensor(SCREAMING_SNAKE_CASE_					)

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



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			lowercase__   					=			tf.convert_to_tensor(SCREAMING_SNAKE_CASE_					)
			lowercase__   					=			tf.cast(0.04_4715  ,					x.dtype					)
			lowercase__   					=			tf.cast(0.79_7884_5608  ,					x.dtype					)

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



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			lowercase__   					=			tf.convert_to_tensor(SCREAMING_SNAKE_CASE_					)
			lowercase__   					=			tf.cast(1.702  ,					x.dtype					)
			return x * tf.math.sigmoid(coeff * x					)



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			return tf.clip_by_value(_gelu(SCREAMING_SNAKE_CASE_					)  ,					-10  ,					10					)



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_=-1					):
			lowercase__					,    lowercase__   					=			tf.split(SCREAMING_SNAKE_CASE_  ,					2  ,					axis=SCREAMING_SNAKE_CASE_					)
			return a * tf.math.sigmoid(SCREAMING_SNAKE_CASE_					)


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



							def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
										return tf.keras.activations.gelu(SCREAMING_SNAKE_CASE_  ,					approximate=SCREAMING_SNAKE_CASE_					)

							lowercase_						=       tf.keras.activations.gelu




							lowercase_						=       approximate_gelu_wrap
else:
							lowercase_						=       _gelu
							lowercase_						=       _gelu_new


lowercase_						=       {
    """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 __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			if activation_string in ACTaFN:
						return ACTaFN[activation_string]
			else:
						raise KeyError(f'''function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys()					)}'''					)









from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
							if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from ...utils.dummy_torch_and_transformers_objects import (
							    VersatileDiffusionDualGuidedPipeline,
							    VersatileDiffusionImageVariationPipeline,
							    VersatileDiffusionPipeline,
							    VersatileDiffusionTextToImagePipeline,
							)
else:
							from .modeling_text_unet import UNetFlatConditionModel
							from .pipeline_versatile_diffusion import VersatileDiffusionPipeline
							from .pipeline_versatile_diffusion_dual_guided import VersatileDiffusionDualGuidedPipeline
							from .pipeline_versatile_diffusion_image_variation import VersatileDiffusionImageVariationPipeline
							from .pipeline_versatile_diffusion_text_to_image import VersatileDiffusionTextToImagePipeline




