




import math

import tensorflow as tf
from packaging import version




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Optional[int])      ->					Dict:






							'''simple docstring'''





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

							return x * cdf




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Optional[int])      ->					Optional[int]:






							'''simple docstring'''





							__UpperCamelCase			:     Dict         =      tf.convert_to_tensor(_lowerCamelCase)
							__UpperCamelCase			:     Optional[int]         =      tf.cast(math.pi		,						x.dtype)
							__UpperCamelCase			:     str         =      tf.cast(0.0_4_4_7_1_5		,						x.dtype)
							__UpperCamelCase			:     List[Any]         =      0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi) * (x + coeff * tf.pow(_lowerCamelCase		,						3))))

							return x * cdf




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    List[str])      ->					List[Any]:






							'''simple docstring'''





							__UpperCamelCase			:     List[str]         =      tf.convert_to_tensor(_lowerCamelCase)

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




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    str)      ->					str:






							'''simple docstring'''





							__UpperCamelCase			:     List[Any]         =      tf.convert_to_tensor(_lowerCamelCase)
							__UpperCamelCase			:     Optional[int]         =      tf.cast(0.0_4_4_7_1_5		,						x.dtype)
							__UpperCamelCase			:     Dict         =      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 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Optional[Any])      ->					Dict:






							'''simple docstring'''





							__UpperCamelCase			:     List[str]         =      tf.convert_to_tensor(_lowerCamelCase)
							__UpperCamelCase			:     Dict         =      tf.cast(1.7_0_2		,						x.dtype)
							return x * tf.math.sigmoid(coeff * x)




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Optional[int])      ->					int:






							'''simple docstring'''





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




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    str		,						_lowerCamelCase				:    Union[str, Any]=-1)      ->					Optional[int]:






							'''simple docstring'''





							__UpperCamelCase			:     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 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Optional[Any])      ->					Optional[int]:






									'''simple docstring'''





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

		lowercase						:      Tuple									= tf.keras.activations.gelu




		lowercase						:      Tuple									= approximate_gelu_wrap
else:
		lowercase						:      Optional[Any]									= _gelu
		lowercase						:      List[Any]									= _gelu_new


lowercase						:      Dict									= {
    '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 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Any)      ->					str:






							'''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 typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase						:      Optional[Any]									= {
    'configuration_blip_2': [
        'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Blip2Config',
        'Blip2QFormerConfig',
        'Blip2VisionConfig',
    ],
    'processing_blip_2': ['Blip2Processor'],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		lowercase						:      Tuple									= [
		    'BLIP_2_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'Blip2Model',
		    'Blip2QFormerModel',
		    'Blip2PreTrainedModel',
		    'Blip2ForConditionalGeneration',
		    'Blip2VisionModel',
		]

if TYPE_CHECKING:
		from .configuration_blip_a import (
		    BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    BlipaConfig,
		    BlipaQFormerConfig,
		    BlipaVisionConfig,
		)
		from .processing_blip_a import BlipaProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_blip_a import (
				    BLIP_2_PRETRAINED_MODEL_ARCHIVE_LIST,
				    BlipaForConditionalGeneration,
				    BlipaModel,
				    BlipaPreTrainedModel,
				    BlipaQFormerModel,
				    BlipaVisionModel,
				)

else:
		import sys

		lowercase						:      Dict									= _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)