





import math

import tensorflow as tf
from packaging import version





def      _lowercase					(						_UpperCAmelCase				)						->  Union[str, Any]:
				lowerCamelCase	 =tf.convert_to_tensor(_UpperCAmelCase				)
				lowerCamelCase	 =0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0				)			,      x.dtype				)				))

				return x * cdf





def      _lowercase					(						_UpperCAmelCase				)						->  List[str]:
				lowerCamelCase	 =tf.convert_to_tensor(_UpperCAmelCase				)
				lowerCamelCase	 =tf.cast(math.pi			,      x.dtype				)
				lowerCamelCase	 =tf.cast(0.0_4_4_7_1_5			,      x.dtype				)
				lowerCamelCase	 =0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi				) * (x + coeff * tf.pow(_UpperCAmelCase			,      3				))				))

				return x * cdf





def      _lowercase					(						_UpperCAmelCase				)						->  Tuple:
				lowerCamelCase	 =tf.convert_to_tensor(_UpperCAmelCase				)

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





def      _lowercase					(						_UpperCAmelCase				)						->  Optional[Any]:
				lowerCamelCase	 =tf.convert_to_tensor(_UpperCAmelCase				)
				lowerCamelCase	 =tf.cast(0.0_4_4_7_1_5			,      x.dtype				)
				lowerCamelCase	 =tf.cast(0.7_9_7_8_8_4_5_6_0_8			,      x.dtype				)

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





def      _lowercase					(						_UpperCAmelCase				)						->  List[str]:
				lowerCamelCase	 =tf.convert_to_tensor(_UpperCAmelCase				)
				lowerCamelCase	 =tf.cast(1.7_0_2			,      x.dtype				)
				return x * tf.math.sigmoid(coeff * x				)





def      _lowercase					(						_UpperCAmelCase				)						->  Any:
				return tf.clip_by_value(_gelu(_UpperCAmelCase				)			,      -10			,      10				)





def      _lowercase					(						_UpperCAmelCase			,      _UpperCAmelCase=-1				)						->  List[Any]:
				lowerCamelCase ,  lowerCamelCase	 =tf.split(_UpperCAmelCase			,      2			,      axis=_UpperCAmelCase				)
				return a * tf.math.sigmoid(_UpperCAmelCase				)


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





							def      _lowercase					(						_UpperCAmelCase				)						->  Union[str, Any]:
											return tf.keras.activations.gelu(_UpperCAmelCase			,      approximate=_UpperCAmelCase				)

							UpperCAmelCase__						:			int									=tf.keras.activations.gelu




							UpperCAmelCase__						:			Tuple									=approximate_gelu_wrap
else:
							UpperCAmelCase__						:			Optional[Any]									=_gelu
							UpperCAmelCase__						:			Optional[Any]									=_gelu_new


UpperCAmelCase__						:			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      _lowercase					(						_UpperCAmelCase				)						->  List[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()				)}"""				)












from typing import TYPE_CHECKING

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


UpperCAmelCase__						:			List[Any]									={'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']}

try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__						:			Dict									=['''YolosFeatureExtractor''']
							UpperCAmelCase__						:			List[Any]									=['''YolosImageProcessor''']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__						:			Optional[Any]									=[
							    '''YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''YolosForObjectDetection''',
							    '''YolosModel''',
							    '''YolosPreTrainedModel''',
							]


if TYPE_CHECKING:
							from .configuration_yolos import YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP, YolosConfig, YolosOnnxConfig

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_yolos import YolosFeatureExtractor
														from .image_processing_yolos import YolosImageProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_yolos import (
														    YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST,
														    YolosForObjectDetection,
														    YolosModel,
														    YolosPreTrainedModel,
														)


else:
							import sys

							UpperCAmelCase__						:			Optional[Any]									=_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





