






import copy
import re





class __lowerCamelCase :





	"""simple docstring"""






	UpperCamelCase__								=      "hp"
	UpperCamelCase__								=      {}
	UpperCamelCase__								=      None

	@classmethod
	def        UpperCamelCase    (							cls       ,    UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			prefix
							_UpperCAmelCase									=			defaults
							cls.build_naming_info()

	@staticmethod
	def        UpperCamelCase    (							UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							if len(UpperCAmelCase    ) == 0:
													return ""
							_UpperCAmelCase									=			None
							if any(char.isdigit() for char in word    ):
													raise Exception(F"""Parameters should not contain numbers: '{word}' contains a number"""    )
							if word in info["short_word"]:
													return info["short_word"][word]
							for prefix_len in range(1       ,    len(UpperCAmelCase    ) + 1    ):
													_UpperCAmelCase									=			word[:prefix_len]
													if prefix in info["reverse_short_word"]:
																			continue
													else:
																			_UpperCAmelCase									=			prefix
																			break

							if short_word is None:
													# Paranoid fallback
													def int_to_alphabetic(UpperCAmelCase    ):
																			_UpperCAmelCase									=			''
																			while integer != 0:
																									_UpperCAmelCase									=			chr(ord('A'    ) + integer % 10    ) + s
																									integer //= 10
																			return s

													_UpperCAmelCase									=			0
													while True:
																			_UpperCAmelCase									=			word + '#' + int_to_alphabetic(UpperCAmelCase    )
																			if sword in info["reverse_short_word"]:
																									continue
																			else:
																									_UpperCAmelCase									=			sword
																									break

							_UpperCAmelCase									=			short_word
							_UpperCAmelCase									=			word
							return short_word

	@staticmethod
	def        UpperCamelCase    (							UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			param_name.split('_'    )

							_UpperCAmelCase									=			[TrialShortNamer.shortname_for_word(UpperCAmelCase       ,    UpperCAmelCase    ) for word in words]

							# We try to create a separatorless short name, but if there is a collision we have to fallback
							# to a separated short name
							_UpperCAmelCase									=			['', '_']

							for separator in separators:
													_UpperCAmelCase									=			separator.join(UpperCAmelCase    )
													if shortname not in info["reverse_short_param"]:
																			_UpperCAmelCase									=			shortname
																			_UpperCAmelCase									=			param_name
																			return shortname

							return param_name

	@staticmethod
	def        UpperCamelCase    (							UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			TrialShortNamer.shortname_for_key(UpperCAmelCase       ,    UpperCAmelCase    )
							_UpperCAmelCase									=			short_name
							_UpperCAmelCase									=			param_name

	@classmethod
	def        UpperCamelCase    (							cls    ):
							"""simple docstring"""







							if cls.NAMING_INFO is not None:
													return

							_UpperCAmelCase									=			{
							    'short_word': {},
							    'reverse_short_word': {},
							    'short_param': {},
							    'reverse_short_param': {},
							}

							_UpperCAmelCase									=			list(cls.DEFAULTS.keys()    )

							for k in field_keys:
													cls.add_new_param_name(UpperCAmelCase       ,    UpperCAmelCase    )

							_UpperCAmelCase									=			info

	@classmethod
	def        UpperCamelCase    (							cls       ,    UpperCAmelCase    ):
							"""simple docstring"""







							cls.build_naming_info()
							assert cls.PREFIX is not None
							_UpperCAmelCase									=			[copy.copy(cls.PREFIX    )]

							for k, v in params.items():
													if k not in cls.DEFAULTS:
																			raise Exception(F"""You should provide a default value for the param name {k} with value {v}"""    )
													if v == cls.DEFAULTS[k]:
																			# The default value is not added to the name
																			continue

													_UpperCAmelCase									=			cls.NAMING_INFO['short_param'][k]

													if isinstance(UpperCAmelCase       ,    UpperCAmelCase    ):
																			_UpperCAmelCase									=			1 if v else 0

													_UpperCAmelCase									=			'' if isinstance(UpperCAmelCase       ,    (int, float)    ) else '-'
													_UpperCAmelCase									=			F"""{key}{sep}{v}"""
													name.append(UpperCAmelCase    )

							return "_".join(UpperCAmelCase    )

	@classmethod
	def        UpperCamelCase    (							cls       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			repr[len(cls.PREFIX    ) + 1 :]
							if repr == "":
													_UpperCAmelCase									=			[]
							else:
													_UpperCAmelCase									=			repr.split('_'    )

							_UpperCAmelCase									=			{}

							for value in values:
													if "-" in value:
																			_UpperCAmelCase					, _UpperCAmelCase									=			value.split('-'    )
													else:
																			_UpperCAmelCase									=			re.sub('[0-9.]'       ,    ''       ,    UpperCAmelCase    )
																			_UpperCAmelCase									=			float(re.sub('[^0-9.]'       ,    ''       ,    UpperCAmelCase    )    )

													_UpperCAmelCase									=			cls.NAMING_INFO['reverse_short_param'][p_k]

													_UpperCAmelCase									=			p_v

							for k in cls.DEFAULTS:
													if k not in parameters:
																			_UpperCAmelCase									=			cls.DEFAULTS[k]

							return parameters








from collections import OrderedDict
from typing import Mapping

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


_a      	=  logging.get_logger(__name__)

_a      	=  {
    '''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 __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	UpperCamelCase__								=      "distilbert"
	UpperCamelCase__								=      {
	    "hidden_size": "dim",
	    "num_attention_heads": "n_heads",
	    "num_hidden_layers": "n_layers",
	}

	def __init__(							self       ,    UpperCAmelCase=3_0522       ,    UpperCAmelCase=512       ,    UpperCAmelCase=False       ,    UpperCAmelCase=6       ,    UpperCAmelCase=12       ,    UpperCAmelCase=768       ,    UpperCAmelCase=4 * 768       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase="gelu"       ,    UpperCAmelCase=0.02       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.2       ,    UpperCAmelCase=0       ,    **UpperCAmelCase       ,    ):
							"""simple docstring"""







							_UpperCAmelCase									=			vocab_size
							_UpperCAmelCase									=			max_position_embeddings
							_UpperCAmelCase									=			sinusoidal_pos_embds
							_UpperCAmelCase									=			n_layers
							_UpperCAmelCase									=			n_heads
							_UpperCAmelCase									=			dim
							_UpperCAmelCase									=			hidden_dim
							_UpperCAmelCase									=			dropout
							_UpperCAmelCase									=			attention_dropout
							_UpperCAmelCase									=			activation
							_UpperCAmelCase									=			initializer_range
							_UpperCAmelCase									=			qa_dropout
							_UpperCAmelCase									=			seq_classif_dropout
							super().__init__(**UpperCAmelCase       ,    pad_token_id=UpperCAmelCase    )





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							if self.task == "multiple-choice":
													_UpperCAmelCase									=			{0: 'batch', 1: 'choice', 2: 'sequence'}
							else:
													_UpperCAmelCase									=			{0: 'batch', 1: 'sequence'}
							return OrderedDict(
							    [
							        ('input_ids', dynamic_axis),
							        ('attention_mask', dynamic_axis),
							    ]    )
