

import math

import tensorflow as tf
from packaging import version
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	Union[str, Any]      )							->      int:





    '''simple docstring'''






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

    return x * cdf
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	int      )							->      Optional[Any]:





    '''simple docstring'''






    A__          =   tf.convert_to_tensor(SCREAMING_SNAKE_CASE__      )
    A__          =   tf.cast(math.pi    ,			x.dtype      )
    A__          =   tf.cast(0.04_4715    ,			x.dtype      )
    A__          =   0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi      ) * (x + coeff * tf.pow(SCREAMING_SNAKE_CASE__    ,			3      ))      ))

    return x * cdf
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	int      )							->      Optional[Any]:





    '''simple docstring'''






    A__          =   tf.convert_to_tensor(SCREAMING_SNAKE_CASE__      )

    return x * tf.tanh(tf.math.softplus(SCREAMING_SNAKE_CASE__      )      )
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	Dict      )							->      int:





    '''simple docstring'''






    A__          =   tf.convert_to_tensor(SCREAMING_SNAKE_CASE__      )
    A__          =   tf.cast(0.04_4715    ,			x.dtype      )
    A__          =   tf.cast(0.79_7884_5608    ,			x.dtype      )

    return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)      ))
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	str      )							->      Union[str, Any]:





    '''simple docstring'''






    A__          =   tf.convert_to_tensor(SCREAMING_SNAKE_CASE__      )
    A__          =   tf.cast(1.702    ,			x.dtype      )
    return x * tf.math.sigmoid(coeff * x      )
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	Optional[int]      )							->      Optional[int]:





    '''simple docstring'''






    return tf.clip_by_value(_gelu(SCREAMING_SNAKE_CASE__      )    ,			-10    ,			10      )
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	Optional[int]    ,			SCREAMING_SNAKE_CASE__			:	Tuple=-1      )							->      List[Any]:





    '''simple docstring'''






    A__      ,						A__          =   tf.split(SCREAMING_SNAKE_CASE__    ,			2    ,			axis=SCREAMING_SNAKE_CASE__      )
    return a * tf.math.sigmoid(SCREAMING_SNAKE_CASE__      )


if version.parse(tf.version.VERSION) >= version.parse("2.4"):
     def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	List[str]      )							->      Dict:





         '''simple docstring'''






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

     lowercase_       		=  tf.keras.activations.gelu

     lowercase_       		=  approximate_gelu_wrap
else:
     lowercase_       		=  _gelu
     lowercase_       		=  _gelu_new


lowercase_       		=  {
    "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(    SCREAMING_SNAKE_CASE__			:	Optional[int]      )							->      int:





    '''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


UpperCAmelCase__				   =		{
    "configuration_nllb_moe": [
        "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "NllbMoeConfig",
    ]
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCAmelCase__				   =		[
         "NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST",
         "NllbMoeForConditionalGeneration",
         "NllbMoeModel",
         "NllbMoePreTrainedModel",
         "NllbMoeTop2Router",
         "NllbMoeSparseMLP",
     ]


if TYPE_CHECKING:
     from .configuration_nllb_moe import (
         NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP,
         NllbMoeConfig,
     )

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_nllb_moe import (
              NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST,
              NllbMoeForConditionalGeneration,
              NllbMoeModel,
              NllbMoePreTrainedModel,
              NllbMoeSparseMLP,
              NllbMoeTopaRouter,
          )


else:
     import sys

     UpperCAmelCase__				   =		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


