import math

import tensorflow as tf
from packaging import version



def   __A		(			_A					):



 """simple docstring"""


 __a       =  tf.convert_to_tensor(_A					)
 __a       =  0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0					)							,				x.dtype					)					))

 return x * cdf



def   __A		(			_A					):



 """simple docstring"""


 __a       =  tf.convert_to_tensor(_A					)
 __a       =  tf.cast(math.pi							,				x.dtype					)
 __a       =  tf.cast(0.04_4715							,				x.dtype					)
 __a       =  0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi					) * (x + coeff * tf.pow(_A							,				3					))					))

 return x * cdf



def   __A		(			_A					):



 """simple docstring"""


 __a       =  tf.convert_to_tensor(_A					)

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



def   __A		(			_A					):



 """simple docstring"""


 __a       =  tf.convert_to_tensor(_A					)
 __a       =  tf.cast(0.04_4715							,				x.dtype					)
 __a       =  tf.cast(0.79_7884_5608							,				x.dtype					)

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



def   __A		(			_A					):



 """simple docstring"""


 __a       =  tf.convert_to_tensor(_A					)
 __a       =  tf.cast(1.702							,				x.dtype					)
 return x * tf.math.sigmoid(coeff * x					)



def   __A		(			_A					):



 """simple docstring"""


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



def   __A		(			_A							,				_A=-1					):



 """simple docstring"""


 __a       ,     __a       =  tf.split(_A							,				2							,				axis=_A					)
 return a * tf.math.sigmoid(_A					)


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



  def   __A		(			_A					):



   """simple docstring"""


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

  SCREAMING_SNAKE_CASE :	List[Any]							     =		tf.keras.activations.gelu






  SCREAMING_SNAKE_CASE :	int							     =		approximate_gelu_wrap
else:
  SCREAMING_SNAKE_CASE :	List[str]							     =		_gelu
  SCREAMING_SNAKE_CASE :	Union[str, Any]							     =		_gelu_new


SCREAMING_SNAKE_CASE :	List[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   __A		(			_A					):



 """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()					)}"""					)



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 UnCLIPImageVariationPipeline, UnCLIPPipeline
else:
  from .pipeline_unclip import UnCLIPPipeline
  from .pipeline_unclip_image_variation import UnCLIPImageVariationPipeline
  from .text_proj import UnCLIPTextProjModel


