





from __future__ import annotations

from decimal import Decimal

from numpy import array






def       _A  (      lowerCamelCase   ):
   a__	:						str      		=  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
      a__	:						Union[str, Any]      		=  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
      a__	:						int      		=  [[0.0, 0.0], [0.0, 0.0]]
      a__		,     a__	:						Any      		=  matrix[1][1], matrix[0][0]
      a__		,     a__	:						Any      		=  -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
      a__	:						Any      		=  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
      a__	:						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   )],
      ]
      a__	:						Optional[int]      		=  (d(matrix[1][1]   ) * d(matrix[2][2]   )) - (
          d(matrix[1][2]   ) * d(matrix[2][1]   )
      )
      a__	:						Union[str, Any]      		=  -(
          (d(matrix[1][0]   ) * d(matrix[2][2]   )) - (d(matrix[1][2]   ) * d(matrix[2][0]   ))
      )
      a__	:						Optional[Any]      		=  (d(matrix[1][0]   ) * d(matrix[2][1]   )) - (
          d(matrix[1][1]   ) * d(matrix[2][0]   )
      )
      a__	:						int      		=  -(
          (d(matrix[0][1]   ) * d(matrix[2][2]   )) - (d(matrix[0][2]   ) * d(matrix[2][1]   ))
      )
      a__	:						List[str]      		=  (d(matrix[0][0]   ) * d(matrix[2][2]   )) - (
          d(matrix[0][2]   ) * d(matrix[2][0]   )
      )
      a__	:						Optional[Any]      		=  -(
          (d(matrix[0][0]   ) * d(matrix[2][1]   )) - (d(matrix[0][1]   ) * d(matrix[2][0]   ))
      )
      a__	:						Dict      		=  (d(matrix[0][1]   ) * d(matrix[1][2]   )) - (
          d(matrix[0][2]   ) * d(matrix[1][1]   )
      )
      a__	:						Union[str, Any]      		=  -(
          (d(matrix[0][0]   ) * d(matrix[1][2]   )) - (d(matrix[0][2]   ) * d(matrix[1][0]   ))
      )
      a__	:						Any      		=  (d(matrix[0][0]   ) * d(matrix[1][1]   )) - (
          d(matrix[0][1]   ) * d(matrix[1][0]   )
      )

      # Transpose the cofactor matrix (Adjoint matrix)
      a__	:						Dict      		=  array(lowerCamelCase   )
      for i in range(3   ):
         for j in range(3   ):
            a__	:						Optional[Any]      		=  cofactor_matrix[j][i]

        # Inverse of the matrix using the formula (1/determinant) * adjoint matrix
      a__	:						Tuple      		=  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."   )








import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


SCREAMING_SNAKE_CASE__       :			Optional[Any]			      =						{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

SCREAMING_SNAKE_CASE__       :			List[Any]			      =						{
    """vocab_file""": {
        """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt""",
    },
    """tokenizer_file""": {
        """unc-nlp/lxmert-base-uncased""": (
            """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json"""
        ),
    },
}

SCREAMING_SNAKE_CASE__       :			Any			      =						{
    """unc-nlp/lxmert-base-uncased""": 5_1_2,
}

SCREAMING_SNAKE_CASE__       :			Optional[int]			      =						{
    """unc-nlp/lxmert-base-uncased""": {"""do_lower_case""": True},
}







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						List[str]     		=				VOCAB_FILES_NAMES
   _UpperCamelCase :						str     		=				PRETRAINED_VOCAB_FILES_MAP
   _UpperCamelCase :						List[str]     		=				PRETRAINED_INIT_CONFIGURATION
   _UpperCamelCase :						Optional[int]     		=				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   _UpperCamelCase :						Optional[Any]     		=				LxmertTokenizer





   def __init__( self					,			snake_case=None					,			snake_case=None					,			snake_case=True					,			snake_case="[UNK]"					,			snake_case="[SEP]"					,			snake_case="[PAD]"					,			snake_case="[CLS]"					,			snake_case="[MASK]"					,			snake_case=True					,			snake_case=None					,			**snake_case					,			)				->  Any:
      """simple docstring"""





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

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

      a__	:						str      		=  do_lower_case





   def 	_snake_case ( self					,			snake_case					,			snake_case=None      )				->  List[str]:
      """simple docstring"""





      a__	:						Optional[int]      		=  [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 	_snake_case ( self					,			snake_case					,			snake_case = None      )				->  List[int]:
      """simple docstring"""





      a__	:						Tuple      		=  [self.sep_token_id]
      a__	:						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 	_snake_case ( self					,			snake_case					,			snake_case = None      )				->  Tuple[str]:
      """simple docstring"""





      a__	:						Optional[int]      		=  self._tokenizer.model.save(snake_case					,			name=snake_case      )
      return tuple(snake_case      )

