


from __future__ import annotations

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

class        a	:




							"""simple docstring"""


							def __init__(							self :						Union[str, Any]					,			lowerCamelCase :						Union[str, Any] = None       )			->					None:
														if components is None:
																					__snake_case	:    Dict											=     []
														__snake_case	:    List[str]											=     list(A__       )

							def __len__(							self :						Optional[int]       )			->					int:
														return len(self.__components       )

							def __str__(							self :						str       )			->					str:
														return "(" + ",".join(map(A__					,			self.__components       )       ) + ")"

							def __add__(							self :						Optional[int]					,			lowerCamelCase :						Any       )			->					Vector:
														__snake_case	:    str											=     len(self       )
														if size == len(A__       ):
																					__snake_case	:    Union[str, Any]											=     [self.__components[i] + other.component(A__       ) for i in range(A__       )]
																					return Vector(A__       )
														else:
																					raise Exception("must have the same size"       )

							def __sub__(							self :						str					,			lowerCamelCase :						int       )			->					Vector:
														__snake_case	:    Union[str, Any]											=     len(self       )
														if size == len(A__       ):
																					__snake_case	:    Any											=     [self.__components[i] - other.component(A__       ) for i in range(A__       )]
																					return Vector(A__       )
														else:  # error case
																					raise Exception("must have the same size"       )

							@overload
							def __mul__(							self :						Any					,			lowerCamelCase :						Union[str, Any]       )			->					Vector:
														...

							@overload
							def __mul__(							self :						Optional[int]					,			lowerCamelCase :						List[str]       )			->					float:
														...

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

							def 					__snake_case      (							self :						str       )			->					Vector:
														return Vector(self.__components       )

							def 					__snake_case      (							self :						List[Any]					,			lowerCamelCase :						int       )			->					float:
														if isinstance(A__					,			A__       ) and -len(self.__components       ) <= i < len(self.__components       ):
																					return self.__components[i]
														else:
																					raise Exception("index out of range"       )

							def 					__snake_case      (							self :						Tuple					,			lowerCamelCase :						Optional[Any]					,			lowerCamelCase :						Optional[int]       )			->					None:
														assert -len(self.__components       ) <= pos < len(self.__components       )
														__snake_case	:    str											=     value

							def 					__snake_case      (							self :						Tuple       )			->					float:
														if len(self.__components       ) == 0:
																					raise Exception("Vector is empty"       )
														__snake_case	:    Tuple											=     [c**2 for c in self.__components]
														return math.sqrt(sum(A__       )       )






							def 					__snake_case      (							self :						Dict					,			lowerCamelCase :						Union[str, Any]					,			lowerCamelCase :						str = False       )			->					float:
														__snake_case	:    int											=     self * other
														__snake_case	:    List[str]											=     self.euclidean_length() * other.euclidean_length()
														if deg:
																					return math.degrees(math.acos(num / den       )       )
														else:
																					return math.acos(num / den       )







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







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase			):
							assert isinstance(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_			) and (isinstance(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_			))
							__snake_case	:    Tuple											=     [0] * dimension
							__snake_case	:    Any											=     1
							return Vector(SCREAMING_SNAKE_CASE_			)







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







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase			):
							random.seed(SCREAMING_SNAKE_CASE_			)
							__snake_case	:    Union[str, Any]											=     [random.randint(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_			) for _ in range(SCREAMING_SNAKE_CASE_			)]
							return Vector(SCREAMING_SNAKE_CASE_			)

class        a	:




							"""simple docstring"""


							def __init__(							self :						Any					,			lowerCamelCase :						Union[str, Any]					,			lowerCamelCase :						List[Any]					,			lowerCamelCase :						Dict       )			->					None:
														__snake_case	:    Dict											=     matrix
														__snake_case	:    List[Any]											=     w
														__snake_case	:    Any											=     h

							def __str__(							self :						Tuple       )			->					str:
														__snake_case	:    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 :						Any					,			lowerCamelCase :						Tuple       )			->					Matrix:
														if self.__width == other.width() and self.__height == other.height():
																					__snake_case	:    Union[str, Any]											=     []
																					for i in range(self.__height       ):
																												__snake_case	:    Optional[int]											=     [
																												    self.__matrix[i][j] + other.component(A__					,			A__       )
																												    for j in range(self.__width       )
																												]
																												matrix.append(A__       )
																					return Matrix(A__					,			self.__width					,			self.__height       )
														else:
																					raise Exception("matrix must have the same dimension!"       )

							def __sub__(							self :						Union[str, Any]					,			lowerCamelCase :						Optional[int]       )			->					Matrix:
														if self.__width == other.width() and self.__height == other.height():
																					__snake_case	:    Union[str, Any]											=     []
																					for i in range(self.__height       ):
																												__snake_case	:    List[str]											=     [
																												    self.__matrix[i][j] - other.component(A__					,			A__       )
																												    for j in range(self.__width       )
																												]
																												matrix.append(A__       )
																					return Matrix(A__					,			self.__width					,			self.__height       )
														else:
																					raise Exception("matrices must have the same dimension!"       )

							@overload
							def __mul__(							self :						List[str]					,			lowerCamelCase :						Union[str, Any]       )			->					Matrix:
														...

							@overload
							def __mul__(							self :						List[str]					,			lowerCamelCase :						List[Any]       )			->					Vector:
														...

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

							def 					__snake_case      (							self :						int       )			->					int:
														return self.__height

							def 					__snake_case      (							self :						str       )			->					int:
														return self.__width

							def 					__snake_case      (							self :						Union[str, Any]					,			lowerCamelCase :						int					,			lowerCamelCase :						List[Any]       )			->					float:
														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 					__snake_case      (							self :						Optional[int]					,			lowerCamelCase :						List[str]					,			lowerCamelCase :						int					,			lowerCamelCase :						List[Any]       )			->					None:
														if 0 <= x < self.__height and 0 <= y < self.__width:
																					__snake_case	:    str											=     value
														else:
																					raise Exception("change_component: indices out of bounds"       )

							def 					__snake_case      (							self :						Optional[int]					,			lowerCamelCase :						Dict					,			lowerCamelCase :						Union[str, Any]       )			->					float:
														if self.__height != self.__width:
																					raise Exception("Matrix is not square"       )
														__snake_case	:    List[Any]											=     self.__matrix[:x] + self.__matrix[x + 1 :]
														for i in range(len(A__       )       ):
																					__snake_case	:    Tuple											=     minor[i][:y] + minor[i][y + 1 :]
														return Matrix(A__					,			self.__width - 1					,			self.__height - 1       ).determinant()

							def 					__snake_case      (							self :						List[Any]					,			lowerCamelCase :						Optional[Any]					,			lowerCamelCase :						List[str]       )			->					float:
														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(A__					,			A__       )
														else:
																					raise Exception("Indices out of bounds"       )






							def 					__snake_case      (							self :						Dict       )			->					float:
														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:
																					__snake_case	:    List[Any]											=     [
																					    self.__matrix[0][y] * self.cofactor(0					,			A__       ) for y in range(self.__width       )
																					]
																					return sum(A__       )







def        lowerCAmelCase_  (      __lowerCamelCase			):
							__snake_case	:    str											=     [[0] * n for _ in range(SCREAMING_SNAKE_CASE_			)]
							return Matrix(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_			)







def        lowerCAmelCase_  (      __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase			):
							random.seed(SCREAMING_SNAKE_CASE_			)
							__snake_case	:    Optional[Any]											=     [
							    [random.randint(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_			) for _ in range(SCREAMING_SNAKE_CASE_			)] for _ in range(SCREAMING_SNAKE_CASE_			)
							]
							return Matrix(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_			)





import warnings

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_snake_case  :	Optional[Any]			      =       logging.get_logger(__name__)

_snake_case  :	str			      =       {
    "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json",
    "xlnet-large-cased": "https://huggingface.co/xlnet-large-cased/resolve/main/config.json",
}

class        a	(_lowerCAmelCase   ):




							"""simple docstring"""


							__UpperCAmelCase					:							List[Any]  						=						"xlnet"
							__UpperCAmelCase					:							Dict  						=						["mems"]
							__UpperCAmelCase					:							Tuple  						=						{
							    "n_token": "vocab_size",  # Backward compatibility
							    "hidden_size": "d_model",
							    "num_attention_heads": "n_head",
							    "num_hidden_layers": "n_layer",
							}

							def __init__(							self :						List[Any]					,			lowerCamelCase :						Optional[int]=32000					,			lowerCamelCase :						str=1024					,			lowerCamelCase :						int=24					,			lowerCamelCase :						List[Any]=16					,			lowerCamelCase :						Any=4096					,			lowerCamelCase :						Optional[Any]="gelu"					,			lowerCamelCase :						Optional[Any]=True					,			lowerCamelCase :						Optional[int]="bi"					,			lowerCamelCase :						Union[str, Any]=0.02					,			lowerCamelCase :						Union[str, Any]=1E-12					,			lowerCamelCase :						Dict=0.1					,			lowerCamelCase :						int=512					,			lowerCamelCase :						str=None					,			lowerCamelCase :						Dict=True					,			lowerCamelCase :						str=False					,			lowerCamelCase :						Any=False					,			lowerCamelCase :						Optional[Any]=-1					,			lowerCamelCase :						List[Any]=False					,			lowerCamelCase :						Optional[int]="last"					,			lowerCamelCase :						Dict=True					,			lowerCamelCase :						Union[str, Any]="tanh"					,			lowerCamelCase :						int=0.1					,			lowerCamelCase :						Any=5					,			lowerCamelCase :						List[str]=5					,			lowerCamelCase :						List[Any]=5					,			lowerCamelCase :						Tuple=1					,			lowerCamelCase :						Dict=2					,			**lowerCamelCase :						List[str]					,			)			->					List[Any]:
														__snake_case	:    Optional[Any]											=     vocab_size
														__snake_case	:    Any											=     d_model
														__snake_case	:    int											=     n_layer
														__snake_case	:    Optional[int]											=     n_head
														if d_model % n_head != 0:
																					raise ValueError(F'\'d_model % n_head\' ({d_model % n_head}) should be equal to 0'       )
														if "d_head" in kwargs:
																					if kwargs["d_head"] != d_model // n_head:
																												raise ValueError(
																												    F'`d_head` ({kwargs["d_head"]}) should be equal to `d_model // n_head` ({d_model // n_head})'       )
														__snake_case	:    Any											=     d_model // n_head
														__snake_case	:    Tuple											=     ff_activation
														__snake_case	:    int											=     d_inner
														__snake_case	:    Optional[Any]											=     untie_r
														__snake_case	:    Optional[Any]											=     attn_type

														__snake_case	:    List[str]											=     initializer_range
														__snake_case	:    Tuple											=     layer_norm_eps

														__snake_case	:    str											=     dropout
														__snake_case	:    Any											=     mem_len
														__snake_case	:    Tuple											=     reuse_len
														__snake_case	:    Union[str, Any]											=     bi_data
														__snake_case	:    List[Any]											=     clamp_len
														__snake_case	:    Optional[int]											=     same_length

														__snake_case	:    List[str]											=     summary_type
														__snake_case	:    Any											=     summary_use_proj
														__snake_case	:    Any											=     summary_activation
														__snake_case	:    Optional[int]											=     summary_last_dropout
														__snake_case	:    Dict											=     start_n_top
														__snake_case	:    Optional[Any]											=     end_n_top

														__snake_case	:    List[str]											=     bos_token_id
														__snake_case	:    Any											=     pad_token_id
														__snake_case	:    Optional[Any]											=     eos_token_id

														if "use_cache" in kwargs:
																					warnings.warn(
																					    "The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`"
																					    " instead."					,			lowerCamelCase					,			)
																					__snake_case	:    Any											=     kwargs["use_cache"]

														__snake_case	:    int											=     use_mems_eval
														__snake_case	:    Optional[int]											=     use_mems_train
														super().__init__(pad_token_id=lowerCamelCase					,			bos_token_id=lowerCamelCase					,			eos_token_id=lowerCamelCase					,			**lowerCamelCase       )

							@property
							def 					__snake_case      (							self :						Any       )			->					Optional[int]:
														logger.info(F'The model {self.model_type} is one of the few models that has no sequence length limit.'       )
														return -1






							@max_position_embeddings.setter
							def 					__snake_case      (							self :						Union[str, Any]					,			lowerCamelCase :						Any       )			->					Optional[Any]:
														# Message copied from Transformer-XL documentation
														raise NotImplementedError(
														    F'The model {self.model_type} is one of the few models that has no sequence length limit.'       )

