
import math

import tensorflow as tf
from packaging import version





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    snake_case__    =					tf.convert_to_tensor(__lowerCAmelCase				)
    snake_case__    =					0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0				)     ,		x.dtype				)				))

    return x * cdf





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    snake_case__    =					tf.convert_to_tensor(__lowerCAmelCase				)
    snake_case__    =					tf.cast(math.pi     ,		x.dtype				)
    snake_case__    =					tf.cast(0.044_715     ,		x.dtype				)
    snake_case__    =					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				):
    snake_case__    =					tf.convert_to_tensor(__lowerCAmelCase				)

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





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    snake_case__    =					tf.convert_to_tensor(__lowerCAmelCase				)
    snake_case__    =					tf.cast(0.044_715     ,		x.dtype				)
    snake_case__    =					tf.cast(0.7_978_845_608     ,		x.dtype				)

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





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    snake_case__    =					tf.convert_to_tensor(__lowerCAmelCase				)
    snake_case__    =					tf.cast(1.702     ,		x.dtype				)
    return x * tf.math.sigmoid(coeff * x				)





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    return tf.clip_by_value(_gelu(__lowerCAmelCase				)     ,		-10     ,		10				)





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase     ,		__lowerCAmelCase=-1				):
    snake_case__    ,       snake_case__    =					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				):
         return tf.keras.activations.gelu(__lowerCAmelCase     ,		approximate=__lowerCAmelCase				)

     __magic_name__  							=	tf.keras.activations.gelu





     __magic_name__  							=	approximate_gelu_wrap
else:
     __magic_name__  							=	_gelu
     __magic_name__  							=	_gelu_new


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





# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script dumps information about the environment

import os
import sys

import transformers


__magic_name__  							=	'''3'''

print('''Python version:''', sys.version)
print('''transformers version:''', transformers.__version__)

try:
     import torch

     print('''Torch version:''', torch.__version__)
     print('''Cuda available:''', torch.cuda.is_available())
     print('''Cuda version:''', torch.version.cuda)
     print('''CuDNN version:''', torch.backends.cudnn.version())
     print('''Number of GPUs available:''', torch.cuda.device_count())
     print('''NCCL version:''', torch.cuda.nccl.version())
except ImportError:
     print('''Torch version:''', None)

try:
     import deepspeed

     print('''DeepSpeed version:''', deepspeed.__version__)
except ImportError:
     print('''DeepSpeed version:''', None)

try:
     import tensorflow as tf

     print('''TensorFlow version:''', tf.__version__)
     print('''TF GPUs available:''', bool(tf.config.list_physical_devices('''GPU''')))
     print('''Number of TF GPUs available:''', len(tf.config.list_physical_devices('''GPU''')))
except ImportError:
     print('''TensorFlow version:''', None)



