

'''simple docstring'''




import math

import tensorflow as tf
from packaging import version




def 						UpperCamelCase	(			a			)				->     int:






     '''simple docstring'''
     __magic_name__						       =    tf.convert_to_tensor(a			)
     __magic_name__						       =    0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0			)		,						x.dtype			)			))

     return x * cdf




def 						UpperCamelCase	(			a			)				->     Dict:






     '''simple docstring'''
     __magic_name__						       =    tf.convert_to_tensor(a			)
     __magic_name__						       =    tf.cast(math.pi		,						x.dtype			)
     __magic_name__						       =    tf.cast(0.04_47_15		,						x.dtype			)
     __magic_name__						       =    0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi			) * (x + coeff * tf.pow(a		,						3			))			))

     return x * cdf




def 						UpperCamelCase	(			a			)				->     Union[str, Any]:






     '''simple docstring'''
     __magic_name__						       =    tf.convert_to_tensor(a			)

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




def 						UpperCamelCase	(			a			)				->     Optional[Any]:






     '''simple docstring'''
     __magic_name__						       =    tf.convert_to_tensor(a			)
     __magic_name__						       =    tf.cast(0.04_47_15		,						x.dtype			)
     __magic_name__						       =    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	(			a			)				->     int:






     '''simple docstring'''
     __magic_name__						       =    tf.convert_to_tensor(a			)
     __magic_name__						       =    tf.cast(1.7_02		,						x.dtype			)
     return x * tf.math.sigmoid(coeff * x			)




def 						UpperCamelCase	(			a			)				->     Tuple:






     '''simple docstring'''
     return tf.clip_by_value(_gelu(a			)		,						-10		,						10			)




def 						UpperCamelCase	(			a		,						a=-1			)				->     Tuple:






     '''simple docstring'''
     __magic_name__       ,  __magic_name__						       =    tf.split(a		,						2		,						axis=a			)
     return a * tf.math.sigmoid(a			)


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




      def 						UpperCamelCase	(			a			)				->     Optional[int]:






           '''simple docstring'''
           return tf.keras.activations.gelu(a		,						approximate=a			)

      _lowerCAmelCase         =						tf.keras.activations.gelu


      _lowerCAmelCase         =						approximate_gelu_wrap
else:
      _lowerCAmelCase         =						_gelu
      _lowerCAmelCase         =						_gelu_new


_lowerCAmelCase         =						{
    "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	(			a			)				->     List[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'''




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_lowerCAmelCase         =						{"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]}

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _lowerCAmelCase         =						["GLPNFeatureExtractor"]
      _lowerCAmelCase         =						["GLPNImageProcessor"]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _lowerCAmelCase         =						[
          "GLPN_PRETRAINED_MODEL_ARCHIVE_LIST",
          "GLPNForDepthEstimation",
          "GLPNLayer",
          "GLPNModel",
          "GLPNPreTrainedModel",
      ]


if TYPE_CHECKING:
      from .configuration_glpn import GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP, GLPNConfig

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_glpn import GLPNFeatureExtractor
            from .image_processing_glpn import GLPNImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_glpn import (
                GLPN_PRETRAINED_MODEL_ARCHIVE_LIST,
                GLPNForDepthEstimation,
                GLPNLayer,
                GLPNModel,
                GLPNPreTrainedModel,
            )


else:
      import sys

      _lowerCAmelCase         =						_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)






