
import unittest

from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


lowerCamelCase__    :		str          =   get_tests_dir("""fixtures/test_sentencepiece.model""")

@require_sentencepiece
@require_tokenizers
class       _snake_case   (	UpperCAmelCase_  ,						unittest.TestCase							):
 __lowerCAmelCase  :     str        =			XLNetTokenizer
 __lowerCAmelCase  :     List[Any]        =			XLNetTokenizerFast
 __lowerCAmelCase  :     int        =			True
 __lowerCAmelCase  :     str        =			True


 def      lowercase__     (					self):


   '''simple docstring'''




   super().setUp()

   # We have a SentencePiece fixture for testing
   lowercase__  :   List[str]    		=      XLNetTokenizer(UpperCamelCase__					,  keep_accents=UpperCamelCase__)
   tokenizer.sanitize_special_tokens()
   tokenizer.save_pretrained(self.tmpdirname)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   List[Any]    		=      """<s>"""
   lowercase__  :   List[str]    		=      1

   self.assertEqual(self.get_tokenizer()._convert_token_to_id(UpperCamelCase__)					,  UpperCamelCase__)
   self.assertEqual(self.get_tokenizer()._convert_id_to_token(UpperCamelCase__)					,  UpperCamelCase__)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Tuple    		=      list(self.get_tokenizer().get_vocab().keys())

   self.assertEqual(vocab_keys[0]					,  """<unk>""")
   self.assertEqual(vocab_keys[1]					,  """<s>""")
   self.assertEqual(vocab_keys[-1]					,  """<eod>""")
   self.assertEqual(len(UpperCamelCase__)					,  10_06)


 def      lowercase__     (					self):


   '''simple docstring'''




   self.assertEqual(self.get_tokenizer().vocab_size					,  10_00)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Optional[Any]    		=      XLNetTokenizer(UpperCamelCase__					,  keep_accents=UpperCamelCase__)

   lowercase__  :   List[Any]    		=      tokenizer.tokenize("""This is a test""")
   self.assertListEqual(UpperCamelCase__					,  ["""▁This""", """▁is""", """▁a""", """▁t""", """est"""])

   self.assertListEqual(tokenizer.convert_tokens_to_ids(UpperCamelCase__)					,  [2_85, 46, 10, 1_70, 3_82])

   lowercase__  :   Dict    		=      tokenizer.tokenize("""I was born in 92000, and this is falsé.""")
   self.assertListEqual(
       UpperCamelCase__					,  [
           SPIECE_UNDERLINE + """I""",
           SPIECE_UNDERLINE + """was""",
           SPIECE_UNDERLINE + """b""",
           """or""",
           """n""",
           SPIECE_UNDERLINE + """in""",
           SPIECE_UNDERLINE + """""",
           """9""",
           """2""",
           """0""",
           """0""",
           """0""",
           """,""",
           SPIECE_UNDERLINE + """and""",
           SPIECE_UNDERLINE + """this""",
           SPIECE_UNDERLINE + """is""",
           SPIECE_UNDERLINE + """f""",
           """al""",
           """s""",
           """é""",
           """.""",
       ]					,  )
   lowercase__  :   Optional[Any]    		=      tokenizer.convert_tokens_to_ids(UpperCamelCase__)
   self.assertListEqual(UpperCamelCase__					,  [8, 21, 84, 55, 24, 19, 7, 0, 6_02, 3_47, 3_47, 3_47, 3, 12, 66, 46, 72, 80, 6, 0, 4])

   lowercase__  :   Any    		=      tokenizer.convert_ids_to_tokens(UpperCamelCase__)
   self.assertListEqual(
       UpperCamelCase__					,  [
           SPIECE_UNDERLINE + """I""",
           SPIECE_UNDERLINE + """was""",
           SPIECE_UNDERLINE + """b""",
           """or""",
           """n""",
           SPIECE_UNDERLINE + """in""",
           SPIECE_UNDERLINE + """""",
           """<unk>""",
           """2""",
           """0""",
           """0""",
           """0""",
           """,""",
           SPIECE_UNDERLINE + """and""",
           SPIECE_UNDERLINE + """this""",
           SPIECE_UNDERLINE + """is""",
           SPIECE_UNDERLINE + """f""",
           """al""",
           """s""",
           """<unk>""",
           """.""",
       ]					,  )


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   List[Any]    		=      XLNetTokenizer(UpperCamelCase__					,  do_lower_case=UpperCamelCase__)
   lowercase__  :   List[Any]    		=      tokenizer.tokenize("""I was born in 92000, and this is falsé.""")
   self.assertListEqual(
       UpperCamelCase__					,  [
           SPIECE_UNDERLINE + """""",
           """i""",
           SPIECE_UNDERLINE + """was""",
           SPIECE_UNDERLINE + """b""",
           """or""",
           """n""",
           SPIECE_UNDERLINE + """in""",
           SPIECE_UNDERLINE + """""",
           """9""",
           """2""",
           """0""",
           """0""",
           """0""",
           """,""",
           SPIECE_UNDERLINE + """and""",
           SPIECE_UNDERLINE + """this""",
           SPIECE_UNDERLINE + """is""",
           SPIECE_UNDERLINE + """f""",
           """al""",
           """se""",
           """.""",
       ]					,  )
   self.assertListEqual(tokenizer.tokenize("""H\u00E9llo""")					,  ["""▁he""", """ll""", """o"""])


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   str    		=      XLNetTokenizer(UpperCamelCase__					,  do_lower_case=UpperCamelCase__)
   lowercase__  :   Tuple    		=      tokenizer.tokenize("""I was born in 92000, and this is falsé.""")
   self.assertListEqual(
       UpperCamelCase__					,  [
           SPIECE_UNDERLINE + """I""",
           SPIECE_UNDERLINE + """was""",
           SPIECE_UNDERLINE + """b""",
           """or""",
           """n""",
           SPIECE_UNDERLINE + """in""",
           SPIECE_UNDERLINE + """""",
           """9""",
           """2""",
           """0""",
           """0""",
           """0""",
           """,""",
           SPIECE_UNDERLINE + """and""",
           SPIECE_UNDERLINE + """this""",
           SPIECE_UNDERLINE + """is""",
           SPIECE_UNDERLINE + """f""",
           """al""",
           """se""",
           """.""",
       ]					,  )


 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Any    		=      XLNetTokenizer.from_pretrained("""xlnet-base-cased""")

   lowercase__  :   str    		=      tokenizer.encode("""sequence builders"""					,  add_special_tokens=UpperCamelCase__)
   lowercase__  :   str    		=      tokenizer.encode("""multi-sequence build"""					,  add_special_tokens=UpperCamelCase__)

   lowercase__  :   Optional[int]    		=      tokenizer.build_inputs_with_special_tokens(UpperCamelCase__)
   lowercase__  :   str    		=      tokenizer.build_inputs_with_special_tokens(UpperCamelCase__					,  UpperCamelCase__)

   assert encoded_sentence == text + [4, 3]
   assert encoded_pair == text + [4] + text_a + [4, 3]



 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Tuple    		=      {"""input_ids""": [[17, 2_14_42, 2_70, 17, 10, 1_46_45, 3_18, 34, 17, 45_46, 31_45, 7_87, 13, 77_52, 2_20_18, 23, 21, 17, 45_46, 31_45, 7_87, 13, 33_52, 1_44_31, 13, 55_00, 11, 11_76, 5_80, 13, 1_68_19, 47_97, 23, 17, 10, 1_71_35, 6_58, 19, 4_57, 79_32, 13, 1_84, 19, 31_54, 1_71_35, 64_68, 19, 14_04, 1_22_69, 19, 42_29, 53_56, 1_62_64, 46, 19, 17, 2_05_45, 1_03_95, 9, 9, 9, 11, 28, 64_21, 95_31, 2_07_29, 17, 10, 3_53, 1_70_22, 11, 21, 64_21, 95_31, 1_69_49, 17, 10, 1_15_09, 7_53, 11, 33, 95, 24_21, 73_85, 9_56, 1_44_31, 26_26, 25, 8_42, 73_85, 48_36, 21, 14_29, 22_72, 98_55, 31_20, 1_61, 2_47_38, 19, 1_32_03, 6_58, 2_18, 7_87, 21, 4_30, 1_84_82, 8_47, 26_37, 9, 4, 3], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3_22, 2_21_78, 27, 10_64, 22, 9_56, 13, 1_11_01, 14_29, 58_54, 2_43_13, 1_89_53, 40, 4_22, 2_43_66, 68, 17_58, 37, 1_04_83, 1_42_57, 31, 2_07, 2_63, 21, 2_03, 37_73, 25, 71, 97_35, 9, 4, 3], [5, 5, 5, 5, 5, 5, 5, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]}  # noqa: E501
   # fmt: on

   self.tokenizer_integration_test_util(
       expected_encoding=UpperCamelCase__					,  model_name="""xlnet-base-cased"""					,  revision="""c841166438c31ec7ca9a106dee7bb312b73ae511"""					,  )








from __future__ import annotations

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



class       _snake_case   :


 def __init__(					self					,  SCREAMING_SNAKE_CASE_ = None):


   '''simple docstring'''




   if components is None:
     lowercase__  :   List[str]    		=      []
   lowercase__  :   Dict    		=      list(SCREAMING_SNAKE_CASE_)


 def __len__(					self):


   '''simple docstring'''




   return len(self.__components)


 def __str__(					self):


   '''simple docstring'''




   return "(" + ",".join(map(SCREAMING_SNAKE_CASE_					,  self.__components)) + ")"


 def __add__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   Optional[Any]    		=      len(self)
   if size == len(SCREAMING_SNAKE_CASE_):
     lowercase__  :   List[str]    		=      [self.__components[i] + other.component(SCREAMING_SNAKE_CASE_) for i in range(SCREAMING_SNAKE_CASE_)]
     return Vector(SCREAMING_SNAKE_CASE_)
   else:
     raise Exception("""must have the same size""")


 def __sub__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   List[Any]    		=      len(self)
   if size == len(SCREAMING_SNAKE_CASE_):
     lowercase__  :   Optional[Any]    		=      [self.__components[i] - other.component(SCREAMING_SNAKE_CASE_) for i in range(SCREAMING_SNAKE_CASE_)]
     return Vector(SCREAMING_SNAKE_CASE_)
   else:  # error case
     raise Exception("""must have the same size""")


 @overload
 def __mul__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   ...


 @overload
 def __mul__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   ...


 def __mul__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




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


 def      lowercase__     (					self):


   '''simple docstring'''




   return Vector(self.__components)


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   if isinstance(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_) and -len(self.__components) <= i < len(self.__components):
     return self.__components[i]
   else:
     raise Exception("""index out of range""")


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   assert -len(self.__components) <= pos < len(self.__components)
   lowercase__  :   List[Any]    		=      value


 def      lowercase__     (					self):


   '''simple docstring'''




   if len(self.__components) == 0:
     raise Exception("""Vector is empty""")
   lowercase__  :   Union[str, Any]    		=      [c**2 for c in self.__components]
   return math.sqrt(sum(SCREAMING_SNAKE_CASE_))



 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_ = False):


   '''simple docstring'''




   lowercase__  :   Union[str, Any]    		=      self * other
   lowercase__  :   Optional[Any]    		=      self.euclidean_length() * other.euclidean_length()
   if deg:
     return math.degrees(math.acos(num / den))
   else:
     return math.acos(num / den)

def 		UpperCamelCase	(      lowercase_   )		->	Vector:


  '''simple docstring'''






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

def 		UpperCamelCase	(      lowercase_ , lowercase_   )		->	Vector:


  '''simple docstring'''






  assert isinstance(lowercase_ , lowercase_   ) and (isinstance(lowercase_ , lowercase_   ))
  lowercase__  :   Union[str, Any]    		=      [0] * dimension
  lowercase__  :   Any    		=      1
  return Vector(lowercase_   )

def 		UpperCamelCase	(      lowercase_ , lowercase_ , lowercase_   )		->	Vector:


  '''simple docstring'''






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

def 		UpperCamelCase	(      lowercase_ , lowercase_ , lowercase_   )		->	Vector:


  '''simple docstring'''






  random.seed(lowercase_   )
  lowercase__  :   int    		=      [random.randint(lowercase_ , lowercase_   ) for _ in range(lowercase_   )]
  return Vector(lowercase_   )



class       _snake_case   :


 def __init__(					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   List[Any]    		=      matrix
   lowercase__  :   Any    		=      w
   lowercase__  :   Any    		=      h


 def __str__(					self):


   '''simple docstring'''




   lowercase__  :   str    		=      """"""
   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					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   if self.__width == other.width() and self.__height == other.height():
     lowercase__  :   Tuple    		=      []
     for i in range(self.__height):
       lowercase__  :   Tuple    		=      [
           self.__matrix[i][j] + other.component(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_)
           for j in range(self.__width)
       ]
       matrix.append(SCREAMING_SNAKE_CASE_)
     return Matrix(SCREAMING_SNAKE_CASE_					,  self.__width					,  self.__height)
   else:
     raise Exception("""matrix must have the same dimension!""")


 def __sub__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




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


 @overload
 def __mul__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   ...


 @overload
 def __mul__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   ...


 def __mul__(					self					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




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


 def      lowercase__     (					self):


   '''simple docstring'''




   return self.__height


 def      lowercase__     (					self):


   '''simple docstring'''




   return self.__width


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   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      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   if 0 <= x < self.__height and 0 <= y < self.__width:
     lowercase__  :   Tuple    		=      value
   else:
     raise Exception("""change_component: indices out of bounds""")


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   if self.__height != self.__width:
     raise Exception("""Matrix is not square""")
   lowercase__  :   List[Any]    		=      self.__matrix[:x] + self.__matrix[x + 1 :]
   for i in range(len(SCREAMING_SNAKE_CASE_)):
     lowercase__  :   List[str]    		=      minor[i][:y] + minor[i][y + 1 :]
   return Matrix(SCREAMING_SNAKE_CASE_					,  self.__width - 1					,  self.__height - 1).determinant()


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   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(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_)
   else:
     raise Exception("""Indices out of bounds""")



 def      lowercase__     (					self):


   '''simple docstring'''




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

def 		UpperCamelCase	(      lowercase_   )		->	Matrix:


  '''simple docstring'''






  lowercase__  :   list[list[float]]    		=      [[0] * n for _ in range(lowercase_   )]
  return Matrix(lowercase_ , lowercase_ , lowercase_   )



def 		UpperCamelCase	(      lowercase_ , lowercase_ , lowercase_ , lowercase_   )		->	Matrix:


  '''simple docstring'''






  random.seed(lowercase_   )
  lowercase__  :   list[list[float]]    		=      [
      [random.randint(lowercase_ , lowercase_   ) for _ in range(lowercase_   )] for _ in range(lowercase_   )
  ]
  return Matrix(lowercase_ , lowercase_ , lowercase_   )






