



from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload

class      __magic_name__						:







							def __init__(							self :	int     ,_UpperCAmelCase :	Collection[float] | None = None		):
									if components is None:
											_a					:				Tuple				=							[]
									_a					:				Optional[int]				=							list(_UpperCAmelCase		)







							def __len__(							self :	int		):
									return len(self.__components		)







							def __str__(							self :	Tuple		):
									return "(" + ",".join(map(_UpperCAmelCase     ,self.__components		)		) + ")"







							def __add__(							self :	Optional[Any]     ,_UpperCAmelCase :	Vector		):
									_a					:				str				=							len(self		)
									if size == len(_UpperCAmelCase		):
											_a					:				Optional[Any]				=							[self.__components[i] + other.component(_UpperCAmelCase		) for i in range(_UpperCAmelCase		)]
											return Vector(_UpperCAmelCase		)
									else:
											raise Exception('must have the same size'		)







							def __sub__(							self :	Optional[Any]     ,_UpperCAmelCase :	Vector		):
									_a					:				str				=							len(self		)
									if size == len(_UpperCAmelCase		):
											_a					:				str				=							[self.__components[i] - other.component(_UpperCAmelCase		) for i in range(_UpperCAmelCase		)]
											return Vector(_UpperCAmelCase		)
									else:  # error case
											raise Exception('must have the same size'		)







							@overload
							def __mul__(							self :	List[str]     ,_UpperCAmelCase :	float		):
									...







							@overload
							def __mul__(							self :	Optional[Any]     ,_UpperCAmelCase :	Vector		):
									...







							def __mul__(							self :	Optional[int]     ,_UpperCAmelCase :	float | Vector		):
									if isinstance(_UpperCAmelCase     ,(float, int)		):
											_a					:				Optional[Any]				=							[c * other for c in self.__components]
											return Vector(_UpperCAmelCase		)
									elif isinstance(_UpperCAmelCase     ,_UpperCAmelCase		) and len(self		) == len(_UpperCAmelCase		):
											_a					:				List[Any]				=							len(self		)
											_a					:				Union[str, Any]				=							[self.__components[i] * other.component(_UpperCAmelCase		) for i in range(_UpperCAmelCase		)]
											return sum(_UpperCAmelCase		)
									else:  # error case
											raise Exception('invalid operand!'		)







							def 							__lowercase      (							self :	int		):
									return Vector(self.__components		)







							def 							__lowercase      (							self :	Union[str, Any]     ,_UpperCAmelCase :	int		):
									if isinstance(_UpperCAmelCase     ,_UpperCAmelCase		) and -len(self.__components		) <= i < len(self.__components		):
											return self.__components[i]
									else:
											raise Exception('index out of range'		)







							def 							__lowercase      (							self :	List[str]     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	float		):
									assert -len(self.__components		) <= pos < len(self.__components		)
									_a					:				Dict				=							value







							def 							__lowercase      (							self :	Optional[Any]		):
									if len(self.__components		) == 0:
											raise Exception('Vector is empty'		)
									_a					:				Tuple				=							[c**2 for c in self.__components]
									return math.sqrt(sum(_UpperCAmelCase		)		)







							def 							__lowercase      (							self :	Union[str, Any]     ,_UpperCAmelCase :	Vector     ,_UpperCAmelCase :	bool = False		):
									_a					:				Dict				=							self * other
									_a					:				Optional[int]				=							self.euclidean_length() * other.euclidean_length()
									if deg:
											return math.degrees(math.acos(num / den		)		)
									else:
											return math.acos(num / den		)



def 					__lowerCamelCase					(				lowerCAmelCase_  )      ->				Vector:
		assert isinstance(lowerCAmelCase_						,      lowerCAmelCase_  )
		return Vector([0] * dimension  )



def 					__lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_  )      ->				Vector:
		assert isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ) and (isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ))
		_a					:				List[str]				=							[0] * dimension
		_a					:				Optional[Any]				=							1
		return Vector(lowerCAmelCase_  )



def 					__lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_  )      ->				Vector:
		assert (
		    isinstance(lowerCAmelCase_						,      lowerCAmelCase_  )
		    and isinstance(lowerCAmelCase_						,      lowerCAmelCase_  )
		    and (isinstance(lowerCAmelCase_						,      (int, float)  ))
		)
		return x * scalar + y



def 					__lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_  )      ->				Vector:
		random.seed(lowerCAmelCase_  )
		_a					:				int				=							[random.randint(lowerCAmelCase_						,      lowerCAmelCase_  ) for _ in range(lowerCAmelCase_  )]
		return Vector(lowerCAmelCase_  )

class      __magic_name__						:







							def __init__(							self :	Tuple     ,_UpperCAmelCase :	list[list[float]]     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	int		):
									_a					:				str				=							matrix
									_a					:				int				=							w
									_a					:				Any				=							h







							def __str__(							self :	Optional[Any]		):
									_a					:				Optional[Any]				=							''
									for i in range(self.__height		):
											ans += "|"
											for j in range(self.__width		):
													if j < self.__width - 1:
															ans += str(self.__matrix[i][j]		) + ","
													else:
															ans += str(self.__matrix[i][j]		) + "|\n"
									return ans







							def __add__(							self :	Dict     ,_UpperCAmelCase :	Matrix		):
									if self.__width == other.width() and self.__height == other.height():
											_a					:				Any				=							[]
											for i in range(self.__height		):
													_a					:				Optional[Any]				=							[
													    self.__matrix[i][j] + other.component(_UpperCAmelCase     ,_UpperCAmelCase		)
													    for j in range(self.__width		)
													]
													matrix.append(_UpperCAmelCase		)
											return Matrix(_UpperCAmelCase     ,self.__width     ,self.__height		)
									else:
											raise Exception('matrix must have the same dimension!'		)







							def __sub__(							self :	Any     ,_UpperCAmelCase :	Matrix		):
									if self.__width == other.width() and self.__height == other.height():
											_a					:				Tuple				=							[]
											for i in range(self.__height		):
													_a					:				int				=							[
													    self.__matrix[i][j] - other.component(_UpperCAmelCase     ,_UpperCAmelCase		)
													    for j in range(self.__width		)
													]
													matrix.append(_UpperCAmelCase		)
											return Matrix(_UpperCAmelCase     ,self.__width     ,self.__height		)
									else:
											raise Exception('matrices must have the same dimension!'		)







							@overload
							def __mul__(							self :	Union[str, Any]     ,_UpperCAmelCase :	float		):
									...







							@overload
							def __mul__(							self :	str     ,_UpperCAmelCase :	Vector		):
									...







							def __mul__(							self :	Dict     ,_UpperCAmelCase :	float | Vector		):
									if isinstance(_UpperCAmelCase     ,_UpperCAmelCase		):  # matrix-vector
											if len(_UpperCAmelCase		) == self.__width:
													_a					:				str				=							zero_vector(self.__height		)
													for i in range(self.__height		):
															_a					:				Any				=							[
															    self.__matrix[i][j] * other.component(_UpperCAmelCase		)
															    for j in range(self.__width		)
															]
															ans.change_component(_UpperCAmelCase     ,sum(_UpperCAmelCase		)		)
													return ans
											else:
													raise Exception(
													    'vector must have the same size as the '
													    'number of columns of the matrix!'		)
									elif isinstance(_UpperCAmelCase     ,(int, float)		):  # matrix-scalar
											_a					:				Any				=							[
											    [self.__matrix[i][j] * other for j in range(self.__width		)]
											    for i in range(self.__height		)
											]
											return Matrix(_UpperCAmelCase     ,self.__width     ,self.__height		)
									return None







							def 							__lowercase      (							self :	Optional[Any]		):
									return self.__height







							def 							__lowercase      (							self :	Any		):
									return self.__width







							def 							__lowercase      (							self :	int     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	int		):
									if 0 <= x < self.__height and 0 <= y < self.__width:
											return self.__matrix[x][y]
									else:
											raise Exception('change_component: indices out of bounds'		)







							def 							__lowercase      (							self :	str     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	float		):
									if 0 <= x < self.__height and 0 <= y < self.__width:
											_a					:				Union[str, Any]				=							value
									else:
											raise Exception('change_component: indices out of bounds'		)







							def 							__lowercase      (							self :	List[Any]     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	int		):
									if self.__height != self.__width:
											raise Exception('Matrix is not square'		)
									_a					:				List[str]				=							self.__matrix[:x] + self.__matrix[x + 1 :]
									for i in range(len(_UpperCAmelCase		)		):
											_a					:				Tuple				=							minor[i][:y] + minor[i][y + 1 :]
									return Matrix(_UpperCAmelCase     ,self.__width - 1     ,self.__height - 1		).determinant()







							def 							__lowercase      (							self :	Optional[int]     ,_UpperCAmelCase :	int     ,_UpperCAmelCase :	int		):
									if self.__height != self.__width:
											raise Exception('Matrix is not square'		)
									if 0 <= x < self.__height and 0 <= y < self.__width:
											return (-1) ** (x + y) * self.minor(_UpperCAmelCase     ,_UpperCAmelCase		)
									else:
											raise Exception('Indices out of bounds'		)







							def 							__lowercase      (							self :	Dict		):
									if self.__height != self.__width:
											raise Exception('Matrix is not square'		)
									if self.__height < 1:
											raise Exception('Matrix has no element'		)
									elif self.__height == 1:
											return self.__matrix[0][0]
									elif self.__height == 2:
											return (
											    self.__matrix[0][0] * self.__matrix[1][1]
											    - self.__matrix[0][1] * self.__matrix[1][0]
											)
									else:
											_a					:				List[str]				=							[
											    self.__matrix[0][y] * self.cofactor(0     ,_UpperCAmelCase		) for y in range(self.__width		)
											]
											return sum(_UpperCAmelCase		)



def 					__lowerCamelCase					(				lowerCAmelCase_  )      ->				Matrix:
		_a					:				list[list[float]]				=							[[0] * n for _ in range(lowerCAmelCase_  )]
		return Matrix(lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_  )



def 					__lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_  )      ->				Matrix:
		random.seed(lowerCAmelCase_  )
		_a					:				list[list[float]]				=							[
		    [random.randint(lowerCAmelCase_						,      lowerCAmelCase_  ) for _ in range(lowerCAmelCase_  )] for _ in range(lowerCAmelCase_  )
		]
		return Matrix(lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_  )









'''simple docstring'''

from collections import OrderedDict
from typing import Mapping

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


__lowerCAmelCase						      =       logging.get_logger(__name__)

__lowerCAmelCase						      =       {
    '''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      __magic_name__						(   _UpperCamelCase       ):
							lowerCAmelCase	:   Optional[int]           = 'distilbert'
							lowerCAmelCase	:   Optional[int]           = {
							    'hidden_size': 'dim',
							    'num_attention_heads': 'n_heads',
							    'num_hidden_layers': 'n_layers',
							}







							def __init__(							self :	str     ,_UpperCAmelCase :	Optional[Any]=30522     ,_UpperCAmelCase :	int=512     ,_UpperCAmelCase :	int=False     ,_UpperCAmelCase :	str=6     ,_UpperCAmelCase :	int=12     ,_UpperCAmelCase :	Union[str, Any]=768     ,_UpperCAmelCase :	Optional[Any]=4 * 768     ,_UpperCAmelCase :	int=0.1     ,_UpperCAmelCase :	Union[str, Any]=0.1     ,_UpperCAmelCase :	Tuple="gelu"     ,_UpperCAmelCase :	Any=0.02     ,_UpperCAmelCase :	List[Any]=0.1     ,_UpperCAmelCase :	Dict=0.2     ,_UpperCAmelCase :	Union[str, Any]=0     ,**_UpperCAmelCase :	List[Any]     ,):
									_a					:				Optional[Any]				=							vocab_size
									_a					:				Dict				=							max_position_embeddings
									_a					:				Optional[int]				=							sinusoidal_pos_embds
									_a					:				List[Any]				=							n_layers
									_a					:				Any				=							n_heads
									_a					:				int				=							dim
									_a					:				Optional[Any]				=							hidden_dim
									_a					:				str				=							dropout
									_a					:				Optional[Any]				=							attention_dropout
									_a					:				Any				=							activation
									_a					:				Tuple				=							initializer_range
									_a					:				Union[str, Any]				=							qa_dropout
									_a					:				List[Any]				=							seq_classif_dropout
									super().__init__(**_UpperCAmelCase     ,pad_token_id=_UpperCAmelCase		)

class      __magic_name__						(   _UpperCamelCase       ):







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




