
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     ,		__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 __future__ import annotations

import math
from collections import Counter
from string import ascii_lowercase




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    str)      ->					None:






							'''simple docstring'''





							__UpperCamelCase     ,		__UpperCamelCase			:     Optional[Any]         =      analyze_text(_lowerCamelCase)
							__UpperCamelCase			:     List[str]         =      list(" " + ascii_lowercase)
							# what is our total sum of probabilities.
							__UpperCamelCase			:     Any         =      sum(single_char_strings.values())

							# one length string
							__UpperCamelCase			:     Optional[Any]         =      0
							# for each alpha we go in our dict and if it is in it we calculate entropy
							for ch in my_alphas:
														if ch in single_char_strings:
																					__UpperCamelCase			:     List[Any]         =      single_char_strings[ch]
																					__UpperCamelCase			:     List[str]         =      my_str / all_sum
																					my_fir_sum += prob * math.loga(_lowerCamelCase)  # entropy formula.

    # print entropy
							print(F'{round(-1 * my_fir_sum):.1f}')

							# two len string
							__UpperCamelCase			:     Optional[Any]         =      sum(two_char_strings.values())
							__UpperCamelCase			:     Tuple         =      0
							# for each alpha (two in size) calculate entropy.
							for cha in my_alphas:
														for cha in my_alphas:
																					__UpperCamelCase			:     List[str]         =      cha + cha
																					if sequence in two_char_strings:
																												__UpperCamelCase			:     Optional[Any]         =      two_char_strings[sequence]
																												__UpperCamelCase			:     Any         =      int(_lowerCamelCase) / all_sum
																												my_sec_sum += prob * math.loga(_lowerCamelCase)

    # print second entropy
							print(F'{round(-1 * my_sec_sum):.1f}')

							# print the difference between them
							print(F'{round((-1 * my_sec_sum) - (-1 * my_fir_sum)):.1f}')




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    str)      ->					tuple[dict, dict]:






							'''simple docstring'''





							__UpperCamelCase			:     Tuple         =      Counter()  # type: ignore
							__UpperCamelCase			:     Any         =      Counter()  # type: ignore
							single_char_strings[text[-1]] += 1

							# first case when we have space at start.
							two_char_strings[" " + text[0]] += 1
							for i in range(0		,						len(_lowerCamelCase) - 1):
														single_char_strings[text[i]] += 1
														two_char_strings[text[i : i + 2]] += 1
							return single_char_strings, two_char_strings




def 			_SCREAMING_SNAKE_CASE      (	)      ->					List[str]:






							'''simple docstring'''





							import doctest

							doctest.testmod()
							# text = (
							#     "Had repulsive dashwoods suspicion sincerity but advantage now him. Remark "
							#     "easily garret nor nay. Civil those mrs enjoy shy fat merry. You greatest "
							#     "jointure saw horrible. He private he on be imagine suppose. Fertile "
							#     "beloved evident through no service elderly is. Blind there if every no so "
							#     "at. Own neglected you preferred way sincerity delivered his attempted. To "
							#     "of message cottage windows do besides against uncivil.  Delightful "
							#     "unreserved impossible few estimating men favourable see entreaties. She "
							#     "propriety immediate was improving. He or entrance humoured likewise "
							#     "moderate. Much nor game son say feel. Fat make met can must form into "
							#     "gate. Me we offending prevailed discovery. "
							# )

							# calculate_prob(text)


if __name__ == "__main__":
		main()