

"""simple docstring"""






from __future__ import annotations

from decimal import Decimal

from numpy import array

def 		lowerCamelCase__		(					_lowerCamelCase   ):

				'''simple docstring'''



				_lowerCAmelCase       :   Any  =    Decimal

				# Check if the provided matrix has 2 rows and 2 columns
				# since this implementation only works for 2x2 matrices
				if len(_lowerCamelCase   ) == 2 and len(matrix[0]   ) == 2 and len(matrix[1]   ) == 2:
								# Calculate the determinant of the matrix
								_lowerCAmelCase       :   Tuple  =    float(
								    d(matrix[0][0]   ) * d(matrix[1][1]   ) - d(matrix[1][0]   ) * d(matrix[0][1]   )   )
								if determinant == 0:
												raise ValueError('This matrix has no inverse.'   )

								# Creates a copy of the matrix with swapped positions of the elements
								_lowerCAmelCase       :   Optional[int]  =    [[0.0, 0.0], [0.0, 0.0]]
								_lowerCAmelCase       :   Optional[Any]  =    matrix[1][1], matrix[0][0]
								_lowerCAmelCase       :   Optional[int]  =    -matrix[1][0], -matrix[0][1]

								# Calculate the inverse of the matrix
								return [
								    [(float(d(_lowerCamelCase   )   ) / determinant) or 0.0 for n in row] for row in swapped_matrix
								]
				elif (
				    len(_lowerCamelCase   ) == 3
				    and len(matrix[0]   ) == 3
				    and len(matrix[1]   ) == 3
				    and len(matrix[2]   ) == 3
				):
								# Calculate the determinant of the matrix using Sarrus rule
								_lowerCAmelCase       :   str  =    float(
								    (
								        (d(matrix[0][0]   ) * d(matrix[1][1]   ) * d(matrix[2][2]   ))
								        + (d(matrix[0][1]   ) * d(matrix[1][2]   ) * d(matrix[2][0]   ))
								        + (d(matrix[0][2]   ) * d(matrix[1][0]   ) * d(matrix[2][1]   ))
								    )
								    - (
								        (d(matrix[0][2]   ) * d(matrix[1][1]   ) * d(matrix[2][0]   ))
								        + (d(matrix[0][1]   ) * d(matrix[1][0]   ) * d(matrix[2][2]   ))
								        + (d(matrix[0][0]   ) * d(matrix[1][2]   ) * d(matrix[2][1]   ))
								    )   )
								if determinant == 0:
												raise ValueError('This matrix has no inverse.'   )

								# Creating cofactor matrix
								_lowerCAmelCase       :   List[Any]  =    [
								    [d(0.0   ), d(0.0   ), d(0.0   )],
								    [d(0.0   ), d(0.0   ), d(0.0   )],
								    [d(0.0   ), d(0.0   ), d(0.0   )],
								]
								_lowerCAmelCase       :   Any  =    (d(matrix[1][1]   ) * d(matrix[2][2]   )) - (
								    d(matrix[1][2]   ) * d(matrix[2][1]   )
								)
								_lowerCAmelCase       :   Optional[int]  =    -(
								    (d(matrix[1][0]   ) * d(matrix[2][2]   )) - (d(matrix[1][2]   ) * d(matrix[2][0]   ))
								)
								_lowerCAmelCase       :   Union[str, Any]  =    (d(matrix[1][0]   ) * d(matrix[2][1]   )) - (
								    d(matrix[1][1]   ) * d(matrix[2][0]   )
								)
								_lowerCAmelCase       :   List[Any]  =    -(
								    (d(matrix[0][1]   ) * d(matrix[2][2]   )) - (d(matrix[0][2]   ) * d(matrix[2][1]   ))
								)
								_lowerCAmelCase       :   int  =    (d(matrix[0][0]   ) * d(matrix[2][2]   )) - (
								    d(matrix[0][2]   ) * d(matrix[2][0]   )
								)
								_lowerCAmelCase       :   Tuple  =    -(
								    (d(matrix[0][0]   ) * d(matrix[2][1]   )) - (d(matrix[0][1]   ) * d(matrix[2][0]   ))
								)
								_lowerCAmelCase       :   Tuple  =    (d(matrix[0][1]   ) * d(matrix[1][2]   )) - (
								    d(matrix[0][2]   ) * d(matrix[1][1]   )
								)
								_lowerCAmelCase       :   List[Any]  =    -(
								    (d(matrix[0][0]   ) * d(matrix[1][2]   )) - (d(matrix[0][2]   ) * d(matrix[1][0]   ))
								)
								_lowerCAmelCase       :   str  =    (d(matrix[0][0]   ) * d(matrix[1][1]   )) - (
								    d(matrix[0][1]   ) * d(matrix[1][0]   )
								)

								# Transpose the cofactor matrix (Adjoint matrix)
								_lowerCAmelCase       :   Tuple  =    array(_lowerCamelCase   )
								for i in range(3   ):
												for j in range(3   ):
																_lowerCAmelCase       :   Union[str, Any]  =    cofactor_matrix[j][i]

        # Inverse of the matrix using the formula (1/determinant) * adjoint matrix
								_lowerCAmelCase       :   Any  =    array(_lowerCamelCase   )
								for i in range(3   ):
												for j in range(3   ):
																inverse_matrix[i][j] /= d(_lowerCamelCase   )

        # Calculate the inverse of the matrix
								return [[float(d(_lowerCamelCase   )   ) or 0.0 for n in row] for row in inverse_matrix]
				raise ValueError('Please provide a matrix of size 2x2 or 3x3.'   )








"""simple docstring"""






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bert import BertTokenizer


_lowerCAmelCase						=		logging.get_logger(__name__)

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

_lowerCAmelCase						=		{
    """vocab_file""": {
        """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt""",
        """bert-large-uncased""": """https://huggingface.co/bert-large-uncased/resolve/main/vocab.txt""",
        """bert-base-cased""": """https://huggingface.co/bert-base-cased/resolve/main/vocab.txt""",
        """bert-large-cased""": """https://huggingface.co/bert-large-cased/resolve/main/vocab.txt""",
        """bert-base-multilingual-uncased""": (
            """https://huggingface.co/bert-base-multilingual-uncased/resolve/main/vocab.txt"""
        ),
        """bert-base-multilingual-cased""": """https://huggingface.co/bert-base-multilingual-cased/resolve/main/vocab.txt""",
        """bert-base-chinese""": """https://huggingface.co/bert-base-chinese/resolve/main/vocab.txt""",
        """bert-base-german-cased""": """https://huggingface.co/bert-base-german-cased/resolve/main/vocab.txt""",
        """bert-large-uncased-whole-word-masking""": (
            """https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/vocab.txt"""
        ),
        """bert-large-cased-whole-word-masking""": (
            """https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/vocab.txt"""
        ),
        """bert-large-uncased-whole-word-masking-finetuned-squad""": (
            """https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt"""
        ),
        """bert-large-cased-whole-word-masking-finetuned-squad""": (
            """https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt"""
        ),
        """bert-base-cased-finetuned-mrpc""": (
            """https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/vocab.txt"""
        ),
        """bert-base-german-dbmdz-cased""": """https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/vocab.txt""",
        """bert-base-german-dbmdz-uncased""": (
            """https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/vocab.txt"""
        ),
        """TurkuNLP/bert-base-finnish-cased-v1""": (
            """https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/vocab.txt"""
        ),
        """TurkuNLP/bert-base-finnish-uncased-v1""": (
            """https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/vocab.txt"""
        ),
        """wietsedv/bert-base-dutch-cased""": (
            """https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/vocab.txt"""
        ),
    },
    """tokenizer_file""": {
        """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/tokenizer.json""",
        """bert-large-uncased""": """https://huggingface.co/bert-large-uncased/resolve/main/tokenizer.json""",
        """bert-base-cased""": """https://huggingface.co/bert-base-cased/resolve/main/tokenizer.json""",
        """bert-large-cased""": """https://huggingface.co/bert-large-cased/resolve/main/tokenizer.json""",
        """bert-base-multilingual-uncased""": (
            """https://huggingface.co/bert-base-multilingual-uncased/resolve/main/tokenizer.json"""
        ),
        """bert-base-multilingual-cased""": (
            """https://huggingface.co/bert-base-multilingual-cased/resolve/main/tokenizer.json"""
        ),
        """bert-base-chinese""": """https://huggingface.co/bert-base-chinese/resolve/main/tokenizer.json""",
        """bert-base-german-cased""": """https://huggingface.co/bert-base-german-cased/resolve/main/tokenizer.json""",
        """bert-large-uncased-whole-word-masking""": (
            """https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/tokenizer.json"""
        ),
        """bert-large-cased-whole-word-masking""": (
            """https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/tokenizer.json"""
        ),
        """bert-large-uncased-whole-word-masking-finetuned-squad""": (
            """https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json"""
        ),
        """bert-large-cased-whole-word-masking-finetuned-squad""": (
            """https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json"""
        ),
        """bert-base-cased-finetuned-mrpc""": (
            """https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/tokenizer.json"""
        ),
        """bert-base-german-dbmdz-cased""": (
            """https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/tokenizer.json"""
        ),
        """bert-base-german-dbmdz-uncased""": (
            """https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/tokenizer.json"""
        ),
        """TurkuNLP/bert-base-finnish-cased-v1""": (
            """https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/tokenizer.json"""
        ),
        """TurkuNLP/bert-base-finnish-uncased-v1""": (
            """https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/tokenizer.json"""
        ),
        """wietsedv/bert-base-dutch-cased""": (
            """https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/tokenizer.json"""
        ),
    },
}

_lowerCAmelCase						=		{
    """bert-base-uncased""": 5_1_2,
    """bert-large-uncased""": 5_1_2,
    """bert-base-cased""": 5_1_2,
    """bert-large-cased""": 5_1_2,
    """bert-base-multilingual-uncased""": 5_1_2,
    """bert-base-multilingual-cased""": 5_1_2,
    """bert-base-chinese""": 5_1_2,
    """bert-base-german-cased""": 5_1_2,
    """bert-large-uncased-whole-word-masking""": 5_1_2,
    """bert-large-cased-whole-word-masking""": 5_1_2,
    """bert-large-uncased-whole-word-masking-finetuned-squad""": 5_1_2,
    """bert-large-cased-whole-word-masking-finetuned-squad""": 5_1_2,
    """bert-base-cased-finetuned-mrpc""": 5_1_2,
    """bert-base-german-dbmdz-cased""": 5_1_2,
    """bert-base-german-dbmdz-uncased""": 5_1_2,
    """TurkuNLP/bert-base-finnish-cased-v1""": 5_1_2,
    """TurkuNLP/bert-base-finnish-uncased-v1""": 5_1_2,
    """wietsedv/bert-base-dutch-cased""": 5_1_2,
}

_lowerCAmelCase						=		{
    """bert-base-uncased""": {"""do_lower_case""": True},
    """bert-large-uncased""": {"""do_lower_case""": True},
    """bert-base-cased""": {"""do_lower_case""": False},
    """bert-large-cased""": {"""do_lower_case""": False},
    """bert-base-multilingual-uncased""": {"""do_lower_case""": True},
    """bert-base-multilingual-cased""": {"""do_lower_case""": False},
    """bert-base-chinese""": {"""do_lower_case""": False},
    """bert-base-german-cased""": {"""do_lower_case""": False},
    """bert-large-uncased-whole-word-masking""": {"""do_lower_case""": True},
    """bert-large-cased-whole-word-masking""": {"""do_lower_case""": False},
    """bert-large-uncased-whole-word-masking-finetuned-squad""": {"""do_lower_case""": True},
    """bert-large-cased-whole-word-masking-finetuned-squad""": {"""do_lower_case""": False},
    """bert-base-cased-finetuned-mrpc""": {"""do_lower_case""": False},
    """bert-base-german-dbmdz-cased""": {"""do_lower_case""": False},
    """bert-base-german-dbmdz-uncased""": {"""do_lower_case""": True},
    """TurkuNLP/bert-base-finnish-cased-v1""": {"""do_lower_case""": False},
    """TurkuNLP/bert-base-finnish-uncased-v1""": {"""do_lower_case""": True},
    """wietsedv/bert-base-dutch-cased""": {"""do_lower_case""": False},
}







class 	__UpperCamelCase    (    a__						):
  _UpperCAmelCase          =		VOCAB_FILES_NAMES
  _UpperCAmelCase          =		PRETRAINED_VOCAB_FILES_MAP
  _UpperCAmelCase          =		PRETRAINED_INIT_CONFIGURATION
  _UpperCAmelCase          =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  _UpperCAmelCase          =		BertTokenizer

  def __init__(		self    ,_A=None    ,_A=None    ,_A=True    ,_A="[UNK]"    ,_A="[SEP]"    ,_A="[PAD]"    ,_A="[CLS]"    ,_A="[MASK]"    ,_A=True    ,_A=None    ,**_A    ,):
      '''simple docstring'''

      super().__init__(
          _A    ,tokenizer_file=_A    ,do_lower_case=_A    ,unk_token=_A    ,sep_token=_A    ,pad_token=_A    ,cls_token=_A    ,mask_token=_A    ,tokenize_chinese_chars=_A    ,strip_accents=_A    ,**_A    ,)

      _lowerCAmelCase       :   Tuple  =    json.loads(self.backend_tokenizer.normalizer.__getstate__()      )
      if (
          normalizer_state.get('lowercase'    ,_A      ) != do_lower_case
          or normalizer_state.get('strip_accents'    ,_A      ) != strip_accents
          or normalizer_state.get('handle_chinese_chars'    ,_A      ) != tokenize_chinese_chars
      ):
          _lowerCAmelCase       :   Dict  =    getattr(_A    ,normalizer_state.pop('type'      )      )
          _lowerCAmelCase       :   Dict  =    do_lower_case
          _lowerCAmelCase       :   Optional[int]  =    strip_accents
          _lowerCAmelCase       :   Union[str, Any]  =    tokenize_chinese_chars
          _lowerCAmelCase       :   Dict  =    normalizer_class(**_A      )

      _lowerCAmelCase       :   Union[str, Any]  =    do_lower_case

  def __lowerCamelCase		(		self    ,_A    ,_A=None      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Tuple  =    [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 __lowerCamelCase		(		self    ,_A    ,_A = None      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Union[str, Any]  =    [self.sep_token_id]
      _lowerCAmelCase       :   str  =    [self.cls_token_id]
      if token_ids_a is None:
          return len(cls + token_ids_a + sep      ) * [0]
      return len(cls + token_ids_a + sep      ) * [0] + len(token_ids_a + sep      ) * [1]







  def __lowerCamelCase		(		self    ,_A    ,_A = None      ):
      '''simple docstring'''

      _lowerCAmelCase       :   str  =    self._tokenizer.model.save(_A    ,name=_A      )
      return tuple(_A      )





