"""simple docstring"""







from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_a  :  Union[str, Any]=				logging.get_logger(__name__)

_a  :  int=				{
    "distilbert-base-uncased": "https://huggingface.co/distilbert-base-uncased/resolve/main/config.json",
    "distilbert-base-uncased-distilled-squad": (
        "https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/config.json"
    ),
    "distilbert-base-cased": "https://huggingface.co/distilbert-base-cased/resolve/main/config.json",
    "distilbert-base-cased-distilled-squad": (
        "https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/config.json"
    ),
    "distilbert-base-german-cased": "https://huggingface.co/distilbert-base-german-cased/resolve/main/config.json",
    "distilbert-base-multilingual-cased": (
        "https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/config.json"
    ),
    "distilbert-base-uncased-finetuned-sst-2-english": (
        "https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json"
    ),
}

class 	UpperCamelCase    (					lowercase		):
				UpperCAmelCase       :   List[str]					=	"""distilbert"""
				UpperCAmelCase       :   str					=	{
				    """hidden_size""": """dim""",
				    """num_attention_heads""": """n_heads""",
				    """num_hidden_layers""": """n_layers""",
				}



				def __init__(self       :   Dict			,						_A       :   Dict=3_05_22			,						_A       :   Union[str, Any]=5_12			,						_A       :   List[Any]=False			,						_A       :   List[Any]=6			,						_A       :   str=12			,						_A       :   Tuple=7_68			,						_A       :   Union[str, Any]=4 * 7_68			,						_A       :   Any=0.1			,						_A       :   Optional[Any]=0.1			,						_A       :   Optional[Any]="gelu"			,						_A       :   Optional[int]=0.02			,						_A       :   Tuple=0.1			,						_A       :   str=0.2			,						_A       :   int=0			,						**_A       :   Tuple			,						)					->			Tuple:
					__snake_case    :							Any   	=				vocab_size
					__snake_case    :							int   	=				max_position_embeddings
					__snake_case    :							Union[str, Any]   	=				sinusoidal_pos_embds
					__snake_case    :							Optional[int]   	=				n_layers
					__snake_case    :							Dict   	=				n_heads
					__snake_case    :							List[Any]   	=				dim
					__snake_case    :							List[Any]   	=				hidden_dim
					__snake_case    :							List[Any]   	=				dropout
					__snake_case    :							str   	=				attention_dropout
					__snake_case    :							Optional[int]   	=				activation
					__snake_case    :							Optional[int]   	=				initializer_range
					__snake_case    :							Any   	=				qa_dropout
					__snake_case    :							Optional[Any]   	=				seq_classif_dropout
					super().__init__(**_A			,						pad_token_id=_A)







class 	UpperCamelCase    (					lowercase		):



				@property
				def       _lowercase  (self       :   Any)					->			Mapping[str, Mapping[int, str]]:
					if self.task == "multiple-choice":
						__snake_case    :							List[Any]   	=				{0: 'batch', 1: 'choice', 2: 'sequence'}
					else:
						__snake_case    :							str   	=				{0: 'batch', 1: 'sequence'}
					return OrderedDict(
					    [
					        ('input_ids', dynamic_axis),
					        ('attention_mask', dynamic_axis),
					    ])






"""simple docstring"""







import math

import tensorflow as tf
from packaging import version
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Union[str, Any]						)							->    Any:

	'''simple docstring'''





	__snake_case    :							List[str]   	=				tf.convert_to_tensor(UpperCAmelCase_						)
	__snake_case    :							List[str]   	=				0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0						)    ,							x.dtype						)						))

	return x * cdf
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Tuple						)							->    Optional[Any]:

	'''simple docstring'''





	__snake_case    :							Optional[int]   	=				tf.convert_to_tensor(UpperCAmelCase_						)
	__snake_case    :							Any   	=				tf.cast(math.pi    ,							x.dtype						)
	__snake_case    :							List[Any]   	=				tf.cast(0.044_715    ,							x.dtype						)
	__snake_case    :							Union[str, Any]   	=				0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi						) * (x + coeff * tf.pow(UpperCAmelCase_    ,							3						))						))

	return x * cdf
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Tuple						)							->    List[Any]:

	'''simple docstring'''





	__snake_case    :							Optional[int]   	=				tf.convert_to_tensor(UpperCAmelCase_						)

	return x * tf.tanh(tf.math.softplus(UpperCAmelCase_						)						)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Tuple						)							->    List[str]:

	'''simple docstring'''





	__snake_case    :							Union[str, Any]   	=				tf.convert_to_tensor(UpperCAmelCase_						)
	__snake_case    :							Dict   	=				tf.cast(0.044_715    ,							x.dtype						)
	__snake_case    :							int   	=				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 						__UpperCAmelCase       (					UpperCAmelCase_					:       int						)							->    Dict:

	'''simple docstring'''





	__snake_case    :							Any   	=				tf.convert_to_tensor(UpperCAmelCase_						)
	__snake_case    :							Dict   	=				tf.cast(1.702    ,							x.dtype						)
	return x * tf.math.sigmoid(coeff * x						)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Union[str, Any]						)							->    List[Any]:

	'''simple docstring'''





	return tf.clip_by_value(_gelu(UpperCAmelCase_						)    ,							-10    ,							10						)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Union[str, Any]    ,							UpperCAmelCase_					:       Any=-1						)							->    int:

	'''simple docstring'''





	__snake_case	,       __snake_case    :							str   	=				tf.split(UpperCAmelCase_    ,							2    ,							axis=UpperCAmelCase_						)
	return a * tf.math.sigmoid(UpperCAmelCase_						)


if version.parse(tf.version.VERSION) >= version.parse("2.4"):
	def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Tuple						)							->    int:

		'''simple docstring'''





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

	_a  :  Tuple=				tf.keras.activations.gelu

	_a  :  Tuple=				approximate_gelu_wrap
else:
	_a  :  Any=				_gelu
	_a  :  str=				_gelu_new


_a  :  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 						__UpperCAmelCase       (					UpperCAmelCase_					:       Optional[Any]						)							->    List[Any]:

	'''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()						)}"						)





