






"""simple docstring"""






import math

import tensorflow as tf
from packaging import version



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       tf.convert_to_tensor(lowerCAmelCase__				)
				A__							 =       0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0				)       ,x.dtype				)				))

				return x * cdf



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       tf.convert_to_tensor(lowerCAmelCase__				)
				A__							 =       tf.cast(math.pi       ,x.dtype				)
				A__							 =       tf.cast(0.0_4_4_7_1_5       ,x.dtype				)
				A__							 =       0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi				) * (x + coeff * tf.pow(lowerCAmelCase__       ,3				))				))

				return x * cdf



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       tf.convert_to_tensor(lowerCAmelCase__				)

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



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       tf.convert_to_tensor(lowerCAmelCase__				)
				A__							 =       tf.cast(0.0_4_4_7_1_5       ,x.dtype				)
				A__							 =       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  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       tf.convert_to_tensor(lowerCAmelCase__				)
				A__							 =       tf.cast(1.7_0_2       ,x.dtype				)
				return x * tf.math.sigmoid(coeff * x				)



def  __lowerCamelCase					(					lowerCAmelCase__				):
				return tf.clip_by_value(_gelu(lowerCAmelCase__				)       ,-10       ,10				)



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__=-1				):
				A__ ,			A__							 =       tf.split(lowerCAmelCase__       ,2       ,axis=lowerCAmelCase__				)
				return a * tf.math.sigmoid(lowerCAmelCase__				)


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



					def  __lowerCamelCase					(					lowerCAmelCase__				):
									return tf.keras.activations.gelu(lowerCAmelCase__       ,approximate=lowerCAmelCase__				)

					SCREAMING_SNAKE_CASE						:						Any					   =       tf.keras.activations.gelu







					SCREAMING_SNAKE_CASE						:						Tuple					   =       approximate_gelu_wrap
else:
					SCREAMING_SNAKE_CASE						:						str					   =       _gelu
					SCREAMING_SNAKE_CASE						:						Tuple					   =       _gelu_new


SCREAMING_SNAKE_CASE						:						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  __lowerCamelCase					(					lowerCAmelCase__				):
				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 ...processing_utils import ProcessorMixin





class       snake_case_       (    _lowerCamelCase       ):



	"""simple docstring"""

	SCREAMING_SNAKE_CASE_:							List[str]   			=					"""WhisperFeatureExtractor"""
	SCREAMING_SNAKE_CASE_:							Union[str, Any]   			=					"""WhisperTokenizer"""


	def __init__(      self  ,					__a  ,					__a						):


					"""simple docstring"""

					super().__init__(__a  ,					__a						)
					A__							 =       self.feature_extractor
					A__							 =       False


	def       _UpperCAmelCase						(      self  ,					__a=None  ,					__a=None  ,					__a=True						):


					"""simple docstring"""

					return self.tokenizer.get_decoder_prompt_ids(task=__a  ,					language=__a  ,					no_timestamps=__a						)


	def __call__(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

					if self._in_target_context_manager:
									return self.current_processor(*__a  ,					**__a						)

					A__							 =       kwargs.pop('audio'  ,					__a						)
					A__							 =       kwargs.pop('sampling_rate'  ,					__a						)
					A__							 =       kwargs.pop('text'  ,					__a						)
					if len(__a						) > 0:
									A__							 =       args[0]
									A__							 =       args[1:]

					if audio is None and text is None:
									raise ValueError('You need to specify either an `audio` or `text` input to process.'						)

					if audio is not None:
									A__							 =       self.feature_extractor(__a  ,					*__a  ,					sampling_rate=__a  ,					**__a						)
					if text is not None:
									A__							 =       self.tokenizer(__a  ,					**__a						)

					if text is None:
									return inputs

					elif audio is None:
									return encodings
					else:
									A__							 =       encodings['input_ids']
									return inputs


	def       _UpperCAmelCase						(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

					return self.tokenizer.batch_decode(*__a  ,					**__a						)


	def       _UpperCAmelCase						(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

					return self.tokenizer.decode(*__a  ,					**__a						)






	def       _UpperCAmelCase						(      self  ,					__a  ,					__a="np"						):


					"""simple docstring"""

					return self.tokenizer.get_prompt_ids(__a  ,					return_tensors=__a						)


