
from __future__ import annotations

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





class 				UpperCAmelCase :




	'''simple docstring'''





	def __init__(			self   :					Optional[Any]				,A   :					Collection[float] | None = None					):
					if components is None:
									__A       =					[]
					__A       =					list(A					)






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






	def __str__(			self   :					Optional[int]					):
					return "(" + ",".join(map(A				,self.__components					)					) + ")"






	def __add__(			self   :					Optional[int]				,A   :					Vector					):
					__A       =					len(self					)
					if size == len(A					):
									__A       =					[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   :					int				,A   :					Vector					):
					__A       =					len(self					)
					if size == len(A					):
									__A       =					[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   :					List[Any]				,A   :					float					):
					...






	@overload
	def __mul__(			self   :					List[Any]				,A   :					Vector					):
					...






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






	def 							UpperCamelCase_    (			self   :					Tuple					):
					return Vector(self.__components					)






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






	def 							UpperCamelCase_    (			self   :					List[str]				,A   :					int				,A   :					float					):
					assert -len(self.__components					) <= pos < len(self.__components					)
					__A       =					value






	def 							UpperCamelCase_    (			self   :					List[Any]					):
					if len(self.__components					) == 0:
									raise Exception("Vector is empty"					)
					__A       =					[c**2 for c in self.__components]
					return math.sqrt(sum(A					)					)







	def 							UpperCamelCase_    (			self   :					Tuple				,A   :					Vector				,A   :					bool = False					):
					__A       =					self * other
					__A       =					self.euclidean_length() * other.euclidean_length()
					if deg:
									return math.degrees(math.acos(num / den					)					)
					else:
									return math.acos(num / den					)





def 		UpperCAmelCase     (      a_		)						->      Vector:







				"""simple docstring"""



				assert isinstance(a_						,  a_		)
				return Vector([0] * dimension		)


def 		UpperCAmelCase     (      a_						,  a_		)						->      Vector:







				"""simple docstring"""



				assert isinstance(a_						,  a_		) and (isinstance(a_						,  a_		))
				__A       =					[0] * dimension
				__A       =					1
				return Vector(a_		)


def 		UpperCAmelCase     (      a_						,  a_						,  a_		)						->      Vector:







				"""simple docstring"""



				assert (
				    isinstance(a_						,  a_		)
				    and isinstance(a_						,  a_		)
				    and (isinstance(a_						,  (int, float)		))
				)
				return x * scalar + y


def 		UpperCAmelCase     (      a_						,  a_						,  a_		)						->      Vector:







				"""simple docstring"""



				random.seed(a_		)
				__A       =					[random.randint(a_						,  a_		) for _ in range(a_		)]
				return Vector(a_		)





class 				UpperCAmelCase :




	'''simple docstring'''





	def __init__(			self   :					int				,A   :					list[list[float]]				,A   :					int				,A   :					int					):
					__A       =					matrix
					__A       =					w
					__A       =					h






	def __str__(			self   :					Optional[int]					):
					__A       =					""
					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   :					int				,A   :					Matrix					):
					if self.__width == other.width() and self.__height == other.height():
									__A       =					[]
									for i in range(self.__height					):
													__A       =					[
													    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   :					List[Any]				,A   :					Matrix					):
					if self.__width == other.width() and self.__height == other.height():
									__A       =					[]
									for i in range(self.__height					):
													__A       =					[
													    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[Any]				,A   :					float					):
					...






	@overload
	def __mul__(			self   :					Any				,A   :					Vector					):
					...






	def __mul__(			self   :					Dict				,A   :					float | Vector					):
					if isinstance(A				,A					):  # matrix-vector
									if len(A					) == self.__width:
													__A       =					zero_vector(self.__height					)
													for i in range(self.__height					):
																	__A       =					[
																	    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
									__A       =					[
									    [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 							UpperCamelCase_    (			self   :					Union[str, Any]					):
					return self.__height






	def 							UpperCamelCase_    (			self   :					List[Any]					):
					return self.__width






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






	def 							UpperCamelCase_    (			self   :					str				,A   :					int				,A   :					int					):
					if self.__height != self.__width:
									raise Exception("Matrix is not square"					)
					__A       =					self.__matrix[:x] + self.__matrix[x + 1 :]
					for i in range(len(A					)					):
									__A       =					minor[i][:y] + minor[i][y + 1 :]
					return Matrix(A				,self.__width - 1				,self.__height - 1					).determinant()






	def 							UpperCamelCase_    (			self   :					Tuple				,A   :					int				,A   :					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(A				,A					)
					else:
									raise Exception("Indices out of bounds"					)







	def 							UpperCamelCase_    (			self   :					Optional[int]					):
					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       =					[
									    self.__matrix[0][y] * self.cofactor(0				,A					) for y in range(self.__width					)
									]
									return sum(A					)





def 		UpperCAmelCase     (      a_		)						->      Matrix:







				"""simple docstring"""



				__A       =					[[0] * n for _ in range(a_		)]
				return Matrix(a_						,  a_						,  a_		)


def 		UpperCAmelCase     (      a_						,  a_						,  a_						,  a_		)						->      Matrix:







				"""simple docstring"""



				random.seed(a_		)
				__A       =					[
				    [random.randint(a_						,  a_		) for _ in range(a_		)] for _ in range(a_		)
				]
				return Matrix(a_						,  a_						,  a_		)

import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


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

SCREAMING_SNAKE_CASE		:     Dict         =	{"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

SCREAMING_SNAKE_CASE		:     Dict         =	[
    "small",
    "small-base",
    "medium",
    "medium-base",
    "intermediate",
    "intermediate-base",
    "large",
    "large-base",
    "xlarge",
    "xlarge-base",
]

SCREAMING_SNAKE_CASE		:     int         =	{
    "vocab_file": {
        "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt",
        "funnel-transformer/small-base": "https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt",
        "funnel-transformer/medium": "https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt",
        "funnel-transformer/medium-base": (
            "https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt"
        ),
        "funnel-transformer/intermediate": (
            "https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt"
        ),
        "funnel-transformer/intermediate-base": (
            "https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt"
        ),
        "funnel-transformer/large": "https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt",
        "funnel-transformer/large-base": "https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt",
        "funnel-transformer/xlarge": "https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt",
        "funnel-transformer/xlarge-base": (
            "https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt"
        ),
    },
    "tokenizer_file": {
        "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json",
        "funnel-transformer/small-base": (
            "https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/medium": "https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json",
        "funnel-transformer/medium-base": (
            "https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/intermediate": (
            "https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/intermediate-base": (
            "https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/large": "https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json",
        "funnel-transformer/large-base": (
            "https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/xlarge": "https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json",
        "funnel-transformer/xlarge-base": (
            "https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json"
        ),
    },
}
SCREAMING_SNAKE_CASE		:     Any         =	{F'''funnel-transformer/{name}''': 512 for name in _model_names}
SCREAMING_SNAKE_CASE		:     Tuple         =	{F'''funnel-transformer/{name}''': {"do_lower_case": True} for name in _model_names}

class        UpperCamelCase						(				__a				):
						a__		:Dict      =			VOCAB_FILES_NAMES
						a__		:Dict      =			PRETRAINED_VOCAB_FILES_MAP
						a__		:Dict      =			PRETRAINED_INIT_CONFIGURATION
						a__		:str      =			FunnelTokenizer
						a__		:List[str]      =			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						a__		:int      =			2





						def __init__(self			,     __UpperCamelCase=None			,     __UpperCamelCase=None			,     __UpperCamelCase=True			,     __UpperCamelCase="<unk>"			,     __UpperCamelCase="<sep>"			,     __UpperCamelCase="<pad>"			,     __UpperCamelCase="<cls>"			,     __UpperCamelCase="<mask>"			,     __UpperCamelCase="<s>"			,     __UpperCamelCase="</s>"			,     __UpperCamelCase=True			,     __UpperCamelCase=True			,     __UpperCamelCase=None			,     __UpperCamelCase="##"			,     **__UpperCamelCase			,     )				->				List[Any]:
												super().__init__(
												    __UpperCamelCase			,     tokenizer_file=__UpperCamelCase			,     do_lower_case=__UpperCamelCase			,     unk_token=__UpperCamelCase			,     sep_token=__UpperCamelCase			,     pad_token=__UpperCamelCase			,     cls_token=__UpperCamelCase			,     mask_token=__UpperCamelCase			,     bos_token=__UpperCamelCase			,     eos_token=__UpperCamelCase			,     clean_text=__UpperCamelCase			,     tokenize_chinese_chars=__UpperCamelCase			,     strip_accents=__UpperCamelCase			,     wordpieces_prefix=__UpperCamelCase			,     **__UpperCamelCase			,     )

												UpperCamelCase_		:							List[str]  =		json.loads(self.backend_tokenizer.normalizer.__getstate__()						)
												if (
												    normalizer_state.get("""lowercase"""			,     __UpperCamelCase						) != do_lower_case
												    or normalizer_state.get("""strip_accents"""			,     __UpperCamelCase						) != strip_accents
												    or normalizer_state.get("""handle_chinese_chars"""			,     __UpperCamelCase						) != tokenize_chinese_chars
												):
																		UpperCamelCase_		:							List[Any]  =		getattr(__UpperCamelCase			,     normalizer_state.pop("""type"""						)						)
																		UpperCamelCase_		:							Union[str, Any]  =		do_lower_case
																		UpperCamelCase_		:							Tuple  =		strip_accents
																		UpperCamelCase_		:							Dict  =		tokenize_chinese_chars
																		UpperCamelCase_		:							Union[str, Any]  =		normalizer_class(**__UpperCamelCase						)

												UpperCamelCase_		:							Dict  =		do_lower_case





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase=None						)				->				Dict:
												UpperCamelCase_		:							Any  =		[self.cls_token_id] + token_ids_a + [self.sep_token_id]

												if token_ids_a:
																		output += token_ids_a + [self.sep_token_id]

												return output





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase = None						)				->				List[int]:
												UpperCamelCase_		:							Optional[Any]  =		[self.sep_token_id]
												UpperCamelCase_		:							Any  =		[self.cls_token_id]
												if token_ids_a is None:
																		return len(cls						) * [self.cls_token_type_id] + len(token_ids_a + sep						) * [0]
												return len(cls						) * [self.cls_token_type_id] + len(token_ids_a + sep						) * [0] + len(token_ids_a + sep						) * [1]





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase = None						)				->				Tuple[str]:
												UpperCamelCase_		:							int  =		self._tokenizer.model.save(__UpperCamelCase			,     name=__UpperCamelCase						)
												return tuple(__UpperCamelCase						)






