



"""simple docstring"""




import math

import tensorflow as tf
from packaging import version





def 					__snake_case     (      _UpperCAmelCase    ):
    __a							=    tf.convert_to_tensor(_UpperCAmelCase    )
    __a							=    0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0    )       ,			x.dtype    )    ))

    return x * cdf





def 					__snake_case     (      _UpperCAmelCase    ):
    __a							=    tf.convert_to_tensor(_UpperCAmelCase    )
    __a							=    tf.cast(math.pi       ,			x.dtype    )
    __a							=    tf.cast(0.04_47_15       ,			x.dtype    )
    __a							=    0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi    ) * (x + coeff * tf.pow(_UpperCAmelCase       ,			3    ))    ))

    return x * cdf





def 					__snake_case     (      _UpperCAmelCase    ):
    __a							=    tf.convert_to_tensor(_UpperCAmelCase    )

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





def 					__snake_case     (      _UpperCAmelCase    ):
    __a							=    tf.convert_to_tensor(_UpperCAmelCase    )
    __a							=    tf.cast(0.04_47_15       ,			x.dtype    )
    __a							=    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 					__snake_case     (      _UpperCAmelCase    ):
    __a							=    tf.convert_to_tensor(_UpperCAmelCase    )
    __a							=    tf.cast(1.7_02       ,			x.dtype    )
    return x * tf.math.sigmoid(coeff * x    )





def 					__snake_case     (      _UpperCAmelCase    ):
    return tf.clip_by_value(_gelu(_UpperCAmelCase    )       ,			-10       ,			10    )





def 					__snake_case     (      _UpperCAmelCase       ,			_UpperCAmelCase=-1    ):
    __a	,       __a							=    tf.split(_UpperCAmelCase       ,			2       ,			axis=_UpperCAmelCase    )
    return a * tf.math.sigmoid(_UpperCAmelCase    )


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





 def 					__snake_case     (      _UpperCAmelCase    ):
     return tf.keras.activations.gelu(_UpperCAmelCase       ,			approximate=_UpperCAmelCase    )

 __snake_case						:Optional[int]						=					tf.keras.activations.gelu
 __snake_case						:List[str]						=					approximate_gelu_wrap
else:
 __snake_case						:str						=					_gelu
 __snake_case						:Optional[int]						=					_gelu_new


__snake_case						:List[str]						=					{
    '''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 					__snake_case     (      _UpperCAmelCase    ):
    if activation_string in ACTaFN:
        return ACTaFN[activation_string]
    else:
        raise KeyError(f'function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys()    )}'    )










import unittest

from transformers import DonutProcessor


__snake_case						:List[str]						=					'''naver-clova-ix/donut-base'''

class    _A	(     unittest.TestCase   ):



       def 		_lowerCamelCase      (		self							:					List[str]):


           '''simple docstring'''

           __a							=    DonutProcessor.from_pretrained(__SCREAMING_SNAKE_CASE)





       def 		_lowerCamelCase      (		self							:					Tuple):


           '''simple docstring'''

           __a							=    {
               '''name''': '''John Doe''',
               '''age''': '''99''',
               '''city''': '''Atlanta''',
               '''state''': '''GA''',
               '''zip''': '''30301''',
               '''phone''': '''123-4567''',
               '''nicknames''': [{'''nickname''': '''Johnny'''}, {'''nickname''': '''JD'''}],
           }

           __a							=    (
               '''<s_name>John Doe</s_name><s_age>99</s_age><s_city>Atlanta</s_city>'''
               '''<s_state>GA</s_state><s_zip>30301</s_zip><s_phone>123-4567</s_phone>'''
               '''<s_nicknames><s_nickname>Johnny</s_nickname>'''
               '''<sep/><s_nickname>JD</s_nickname></s_nicknames>'''
           )
           __a							=    self.processor.tokenajson(__SCREAMING_SNAKE_CASE)

           self.assertDictEqual(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE)





