



"""simple docstring"""






import math

import tensorflow as tf
from packaging import version





def 							UpperCAmelCase		(		snake_case			:					Optional[int]    ):
					_lowerCAmelCase:int									=  tf.convert_to_tensor(_lowerCamelCase    )
					_lowerCAmelCase:List[Any]									=  0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0    )      ,       x.dtype    )    ))

					return x * cdf





def 							UpperCAmelCase		(		snake_case			:					Optional[int]    ):
					_lowerCAmelCase:Dict									=  tf.convert_to_tensor(_lowerCamelCase    )
					_lowerCAmelCase:Optional[int]									=  tf.cast(math.pi      ,       x.dtype    )
					_lowerCAmelCase:str									=  tf.cast(0.04_47_15      ,       x.dtype    )
					_lowerCAmelCase:List[Any]									=  0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi    ) * (x + coeff * tf.pow(_lowerCamelCase      ,       3    ))    ))

					return x * cdf





def 							UpperCAmelCase		(		snake_case			:					List[str]    ):
					_lowerCAmelCase:List[str]									=  tf.convert_to_tensor(_lowerCamelCase    )

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





def 							UpperCAmelCase		(		snake_case			:					str    ):
					_lowerCAmelCase:List[Any]									=  tf.convert_to_tensor(_lowerCamelCase    )
					_lowerCAmelCase:Optional[int]									=  tf.cast(0.04_47_15      ,       x.dtype    )
					_lowerCAmelCase:Dict									=  tf.cast(0.79_78_84_56_08      ,       x.dtype    )

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





def 							UpperCAmelCase		(		snake_case			:					Optional[Any]    ):
					_lowerCAmelCase:List[str]									=  tf.convert_to_tensor(_lowerCamelCase    )
					_lowerCAmelCase:Dict									=  tf.cast(1.7_02      ,       x.dtype    )
					return x * tf.math.sigmoid(coeff * x    )





def 							UpperCAmelCase		(		snake_case			:					Optional[int]    ):
					return tf.clip_by_value(_gelu(_lowerCamelCase    )      ,       -10      ,       10    )





def 							UpperCAmelCase		(		snake_case			:					str      ,       snake_case			:					Union[str, Any]=-1    ):
					_lowerCAmelCase:List[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		(		snake_case			:					Optional[Any]    ):
									return tf.keras.activations.gelu(_lowerCamelCase      ,       approximate=_lowerCamelCase    )

				UpperCamelCase__						=			tf.keras.activations.gelu





				UpperCamelCase__						=			approximate_gelu_wrap
else:
				UpperCamelCase__						=			_gelu
				UpperCamelCase__						=			_gelu_new


UpperCamelCase__						=			{
    '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		(		snake_case			:					Any    ):





					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"""






# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from ...utils import deprecate
from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline  # noqa: F401


deprecate(
    '''stable diffusion controlnet''',
    '''0.22.0''',
    '''Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffusion.flax_pipeline_stable_diffusion_controlnet is deprecated. Please import `from diffusers import FlaxStableDiffusionControlNetPipeline` instead.''',
    standard_warn=False,
    stacklevel=3,
)






