


from __future__ import annotations

from typing import Any
def 							_UpperCAmelCase    (*UpperCamelCase__					:  List[Any]						):





       if all(_check_not_integer(_A						) for m in matrix_s						):
              for i in matrix_s[1:]:
                     _verify_matrix_sizes(matrix_s[0]    ,							_A						)
              return [[sum(_A						) for t in zip(*_A						)] for m in zip(*_A						)]
       raise TypeError("Expected a matrix, got int/list instead"						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  Any    ,							UpperCamelCase__					:  Optional[Any]						):





       if (
           _check_not_integer(_A						)
           and _check_not_integer(_A						)
           and _verify_matrix_sizes(_A    ,							_A						)
       ):
              return [[i - j for i, j in zip(*_A						)] for m in zip(_A    ,							_A						)]
       raise TypeError("Expected a matrix, got int/list instead"						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  str    ,							UpperCamelCase__					:  Union[str, Any]						):
       return [[x * n for x in row] for row in matrix]
def 							_UpperCAmelCase    (UpperCamelCase__					:  Tuple    ,							UpperCamelCase__					:  Dict						):





       if _check_not_integer(_A						) and _check_not_integer(_A						):
              _A   ,      _A				:	Any       =			_verify_matrix_sizes(_A    ,							_A						)

       if cols[0] != rows[1]:
              _A				:	List[Any]       =			(
                  "Cannot multiply matrix of dimensions "
                  f"({rows[0]},{cols[0]}) and ({rows[1]},{cols[1]})"
              )
              raise ValueError(_A						)
       return [
           [sum(m * n for m, n in zip(_A    ,							_A						)						) for j in zip(*_A						)] for i in matrix_a
       ]
def 							_UpperCAmelCase    (UpperCamelCase__					:  Any						):
       _A				:	Tuple       =			int(_A						)
       return [[int(row == column						) for column in range(_A						)] for row in range(_A						)]
def 							_UpperCAmelCase    (UpperCamelCase__					:  Optional[Any]    ,							UpperCamelCase__					:  int = True						):





       if _check_not_integer(_A						):
              if return_map:
                     return map(_A    ,							zip(*_A						)						)
              else:
                     return list(map(_A    ,							zip(*_A						)						)						)
       raise TypeError("Expected a matrix, got int/list instead"						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  List[Any]    ,							UpperCamelCase__					:  Tuple    ,							UpperCamelCase__					:  str						):
       _A				:	Optional[Any]       =			matrix[:row] + matrix[row + 1 :]
       return [row[:column] + row[column + 1 :] for row in minor]
def 							_UpperCAmelCase    (UpperCamelCase__					:  Union[str, Any]						):





       if len(_A						) == 1:
              return matrix[0][0]

       return sum(
           x * determinant(minor(_A    ,							0    ,							_A						)						) * (-1) ** i
           for i, x in enumerate(matrix[0]						)						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  int						):
       _A				:	Optional[int]       =			determinant(_A						)
       if det == 0:
              return None

       _A				:	int       =			[
           [determinant(minor(_A    ,							_A    ,							_A						)						) for j in range(len(_A						)						)]
           for i in range(len(_A						)						)
       ]

       _A				:	Union[str, Any]       =			[
           [x * (-1) ** (row + col) for col, x in enumerate(matrix_minor[row]						)]
           for row in range(len(_A						)						)
       ]
       _A				:	Optional[Any]       =			list(transpose(_A						)						)
       return scalar_multiply(_A    ,							1 / det						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  List[str]						):
       return not isinstance(_A    ,							_A						) and not isinstance(matrix[0]    ,							_A						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  Optional[int]						):
       return len(_A						), len(matrix[0]						)
def 							_UpperCAmelCase    (UpperCamelCase__					:  List[Any]    ,							UpperCamelCase__					:  Union[str, Any]						):
       _A				:	str       =			_shape(_A						) + _shape(_A						)
       if shape[0] != shape[3] or shape[1] != shape[2]:
              _A				:	Union[str, Any]       =			(
                  "operands could not be broadcast together with shape "
                  f"({shape[0], shape[1]}), ({shape[2], shape[3]})"
              )
              raise ValueError(_A						)
       return (shape[0], shape[2]), (shape[1], shape[3])
def 							_UpperCAmelCase    ():
       _A				:	Union[str, Any]       =			[[12, 10], [3, 9]]
       _A				:	int       =			[[3, 4], [7, 4]]
       _A				:	str       =			[[11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]
       _A				:	Dict       =			[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
       print(f"Add Operation, {add(_A    ,							_A						) = } \n"						)
       print(
           f"Multiply Operation, {multiply(_A    ,							_A						) = } \n"    ,							)
       print(f"Identity: {identity(5						)}\n"						)
       print(f"Minor of {matrix_c} = {minor(_A    ,							1    ,							2						)} \n"						)
       print(f"Determinant of {matrix_b} = {determinant(_A						)} \n"						)
       print(f"Inverse of {matrix_d} = {inverse(_A						)}\n"						)


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()




import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_splinter import SplinterTokenizer


lowerCAmelCase__						=			logging.get_logger(__name__)

lowerCAmelCase__						=			{'vocab_file': 'vocab.txt'}

lowerCAmelCase__						=			{
    'vocab_file': {
        'tau/splinter-base': 'https://huggingface.co/tau/splinter-base/resolve/main/vocab.txt',
        'tau/splinter-base-qass': 'https://huggingface.co/tau/splinter-base-qass/resolve/main/vocab.txt',
        'tau/splinter-large': 'https://huggingface.co/tau/splinter-large/resolve/main/vocab.txt',
        'tau/splinter-large-qass': 'https://huggingface.co/tau/splinter-large-qass/resolve/main/vocab.txt',
    }
}

lowerCAmelCase__						=			{
    'tau/splinter-base': 5_12,
    'tau/splinter-base-qass': 5_12,
    'tau/splinter-large': 5_12,
    'tau/splinter-large-qass': 5_12,
}

lowerCAmelCase__						=			{
    'tau/splinter-base': {'do_lower_case': False},
    'tau/splinter-base-qass': {'do_lower_case': False},
    'tau/splinter-large': {'do_lower_case': False},
    'tau/splinter-large-qass': {'do_lower_case': False},
}







class 					lowerCAmelCase__	(    a):




     '''simple docstring'''
     __SCREAMING_SNAKE_CASE        =			VOCAB_FILES_NAMES
     __SCREAMING_SNAKE_CASE        =			PRETRAINED_VOCAB_FILES_MAP
     __SCREAMING_SNAKE_CASE        =			PRETRAINED_INIT_CONFIGURATION
     __SCREAMING_SNAKE_CASE        =			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     __SCREAMING_SNAKE_CASE        =			SplinterTokenizer


     def __init__(						self			,						__lowerCamelCase=None			,						__lowerCamelCase=None			,						__lowerCamelCase=True			,						__lowerCamelCase="[UNK]"			,						__lowerCamelCase="[SEP]"			,						__lowerCamelCase="[PAD]"			,						__lowerCamelCase="[CLS]"			,						__lowerCamelCase="[MASK]"			,						__lowerCamelCase="[QUESTION]"			,						__lowerCamelCase=True			,						__lowerCamelCase=None			,						**__lowerCamelCase			,						)      ->    Union[str, Any]:
            super().__init__(
                __lowerCamelCase			,						tokenizer_file=__lowerCamelCase			,						do_lower_case=__lowerCamelCase			,						unk_token=__lowerCamelCase			,						sep_token=__lowerCamelCase			,						pad_token=__lowerCamelCase			,						cls_token=__lowerCamelCase			,						mask_token=__lowerCamelCase			,						tokenize_chinese_chars=__lowerCamelCase			,						strip_accents=__lowerCamelCase			,						additional_special_tokens=(question_token,)			,						**__lowerCamelCase			,						)

            _A				:	Tuple       =			json.loads(self.backend_tokenizer.normalizer.__getstate__())
            if (
                pre_tok_state.get("lowercase"			,						__lowerCamelCase) != do_lower_case
                or pre_tok_state.get("strip_accents"			,						__lowerCamelCase) != strip_accents
            ):
                   _A				:	Dict       =			getattr(__lowerCamelCase			,						pre_tok_state.pop("type"))
                   _A				:	List[str]       =			do_lower_case
                   _A				:	Any       =			strip_accents
                   _A				:	int       =			pre_tok_class(**__lowerCamelCase)

            _A				:	int       =			do_lower_case


     @property
     def 			_lowerCamelCase			(						self)      ->    str:
            return self.convert_tokens_to_ids(self.question_token)


     def 			_lowerCamelCase			(						self			,						__lowerCamelCase			,						__lowerCamelCase = None)      ->    List[int]:
            if token_ids_a is None:
                   return [self.cls_token_id] + token_ids_a + [self.sep_token_id]

            _A				:	Tuple       =			[self.cls_token_id]
            _A				:	str       =			[self.sep_token_id]
            _A				:	int       =			[self.question_token_id] + [self.convert_tokens_to_ids(".")]
            if self.padding_side == "right":
                   # Input is question-then-context
                   return cls + token_ids_a + question_suffix + sep + token_ids_a + sep
            else:
                   # Input is context-then-question
                   return cls + token_ids_a + sep + token_ids_a + question_suffix + sep


     def 			_lowerCamelCase			(						self			,						__lowerCamelCase			,						__lowerCamelCase = None)      ->    List[int]:
            _A				:	str       =			[self.sep_token_id]
            _A				:	int       =			[self.cls_token_id]
            _A				:	Union[str, Any]       =			[self.question_token_id] + [self.convert_tokens_to_ids(".")]
            if token_ids_a is None:
                   return len(cls + token_ids_a + sep) * [0]

            if self.padding_side == "right":
                   # Input is question-then-context
                   return len(cls + token_ids_a + question_suffix + sep) * [0] + len(token_ids_a + sep) * [1]
            else:
                   # Input is context-then-question
                   return len(cls + token_ids_a + sep) * [0] + len(token_ids_a + question_suffix + sep) * [1]


     def 			_lowerCamelCase			(						self			,						__lowerCamelCase			,						__lowerCamelCase = None)      ->    Tuple[str]:
            _A				:	Tuple       =			self._tokenizer.model.save(__lowerCamelCase			,						name=__lowerCamelCase)
            return tuple(__lowerCamelCase)
