'''simple docstring'''


import unittest

from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


__snake_case						  =		get_tests_dir("""fixtures/spiece.model""")





@require_sentencepiece
@require_tokenizers
class       _a    (		__a ,				unittest.TestCase      ):


  """simple docstring"""

  A_    							=						DebertaVaTokenizer
  A_    							=						DebertaVaTokenizerFast
  A_    							=						True
  A_    							=						True




  def 		lowerCamelCase__  (		self      :       Dict      ):







    '''simple docstring'''


    super().setUp()

    # We have a SentencePiece fixture for testing
    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				unk_token="""<unk>"""      )
    tokenizer.save_pretrained(self.tmpdirname      )




  def 		lowerCamelCase__  (		self      :       List[Any]   ,				lowercase_      :       str      ):







    '''simple docstring'''


    lowercase_     =       """this is a test"""
    lowercase_     =       """this is a test"""
    return input_text, output_text




  def 		lowerCamelCase__  (		self      :       Optional[int]      ):







    '''simple docstring'''


    lowercase_     =       """<pad>"""
    lowercase_     =       0

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




  def 		lowerCamelCase__  (		self      :       List[Any]      ):







    '''simple docstring'''


    lowercase_     =       list(self.get_tokenizer().get_vocab().keys()      )
    self.assertEqual(vocab_keys[0]   ,				"""<pad>"""      )
    self.assertEqual(vocab_keys[1]   ,				"""<unk>"""      )
    self.assertEqual(vocab_keys[-1]   ,				"""[PAD]"""      )
    self.assertEqual(len(lowercase_      )   ,				30_001      )




  def 		lowerCamelCase__  (		self      :       Union[str, Any]      ):







    '''simple docstring'''


    self.assertEqual(self.get_tokenizer().vocab_size   ,				30_000      )




  def 		lowerCamelCase__  (		self      :       str      ):







    '''simple docstring'''


    lowercase_     =       """ \tHeLLo!how  \n Are yoU?  """
    lowercase_     =       ["""▁hello""", """!""", """how""", """▁are""", """▁you""", """?"""]
    # fmt: on

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				do_lower_case=lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				do_lower_case=lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )




  @unittest.skip("""There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."""      )
  def 		lowerCamelCase__  (		self      :       Any      ):







    '''simple docstring'''


    pass




  @unittest.skip("""There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."""      )
  def 		lowerCamelCase__  (		self      :       str      ):







    '''simple docstring'''


    pass




  def 		lowerCamelCase__  (		self      :       Tuple      ):







    '''simple docstring'''


    lowercase_     =       """I was born in 92000, and this is falsé."""
    lowercase_     =       ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """▁""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """▁""", """.""", ]
    # fmt: on

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       Dict      ):







    '''simple docstring'''


    lowercase_     =       """I was born in 92000, and this is falsé."""
    lowercase_     =       ["""▁i""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """▁""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """▁""", """.""", ]
    # fmt: on

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )
    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )
    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       str      ):







    '''simple docstring'''


    lowercase_     =       """I was born in 92000, and this is falsé."""
    lowercase_     =       ["""▁i""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """.""", ]
    # fmt: on

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       Optional[Any]      ):







    '''simple docstring'''


    lowercase_     =       """I was born in 92000, and this is falsé."""
    lowercase_     =       ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """▁""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """▁""", """.""", ]
    # fmt: on

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       List[Any]      ):







    '''simple docstring'''


    lowercase_     =       """ \tHeLLo!how  \n Are yoU?  """
    lowercase_     =       ["""▁""", """<unk>""", """e""", """<unk>""", """o""", """!""", """how""", """▁""", """<unk>""", """re""", """▁yo""", """<unk>""", """?"""]
    # fmt: on

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				do_lower_case=lowercase_   ,				split_by_punct=lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )

    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       List[str]      ):







    '''simple docstring'''


    lowercase_     =       self.get_tokenizer()
    lowercase_     =       self.get_rust_tokenizer()

    lowercase_     =       """I was born in 92000, and this is falsé."""

    lowercase_     =       tokenizer.convert_ids_to_tokens(tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )      )
    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )
    lowercase_     =       rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       self.get_rust_tokenizer()
    lowercase_     =       tokenizer.encode(lowercase_      )
    lowercase_     =       rust_tokenizer.encode(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       List[Any]      ):







    '''simple docstring'''


    lowercase_     =       """This is a test"""
    lowercase_     =       [13, 1, 4_398, 25, 21, 1_289]
    lowercase_     =       ["""▁""", """T""", """his""", """▁is""", """▁a""", """▁test"""]
    lowercase_     =       ["""▁""", """<unk>""", """his""", """▁is""", """▁a""", """▁test"""]

    lowercase_     =       DebertaVaTokenizer(lowercase_   ,				keep_accents=lowercase_      )
    lowercase_     =       DebertaVaTokenizerFast(lowercase_   ,				keep_accents=lowercase_      )

    lowercase_     =       tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       tokenizer.tokenize(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       rust_tokenizer.tokenize(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )

    # fmt: off
    lowercase_     =       """I was born in 92000, and this is falsé."""
    lowercase_     =       [13, 1, 23, 386, 19, 561, 3_050, 15, 17, 48, 25, 8_256, 18, 1, 9]
    lowercase_     =       ["""▁""", """I""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """é""", """.""", ]
    lowercase_     =       ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """.""", ]
    # fmt: on

    lowercase_     =       tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       tokenizer.tokenize(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       tokenizer.convert_ids_to_tokens(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )

    lowercase_     =       rust_tokenizer.encode(lowercase_   ,				add_special_tokens=lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       rust_tokenizer.tokenize(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )
    lowercase_     =       rust_tokenizer.convert_ids_to_tokens(lowercase_      )
    self.assertListEqual(lowercase_   ,				lowercase_      )




  def 		lowerCamelCase__  (		self      :       List[Any]      ):







    '''simple docstring'''


    lowercase_     =       DebertaVaTokenizer(lowercase_      )

    lowercase_     =       tokenizer.encode("""sequence builders"""      )
    lowercase_     =       tokenizer.encode("""multi-sequence build"""      )

    lowercase_     =       tokenizer.build_inputs_with_special_tokens(lowercase_      )
    lowercase_     =       tokenizer.build_inputs_with_special_tokens(lowercase_   ,				lowercase_      )

    self.assertEqual([tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]   ,				lowercase_      )
    self.assertEqual(
        [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [tokenizer.sep_token_id]   ,				lowercase_   ,				)





  @slow
  def 		lowerCamelCase__  (		self      :       Optional[Any]      ):







    '''simple docstring'''


    lowercase_     =       {"""input_ids""": [[1, 39_867, 36, 19_390, 486, 27, 35_052, 81_436, 18, 60_685, 1_225, 7, 35_052, 81_436, 18, 9_367, 16_899, 18, 15_937, 53, 594, 773, 18, 16_287, 30_465, 36, 15_937, 6, 41_139, 38, 36_979, 60_763, 191, 6, 34_132, 99, 6, 50_538, 390, 43_230, 6, 34_132, 2_779, 20_850, 14, 699, 1_072, 1_194, 36, 382, 10_901, 53, 7, 699, 1_072, 2_084, 36, 20_422, 630, 53, 19, 105, 3_049, 1_896, 1_053, 16_899, 1_506, 11, 37_978, 4_243, 7, 1_237, 31_869, 200, 16_566, 654, 6, 35_052, 81_436, 7, 55_630, 13_593, 4, 2], [1, 26, 15_011, 13, 667, 8, 1_053, 18, 23_611, 1_237, 72_356, 12_820, 34, 104_134, 1_209, 35, 13_313, 6_627, 21, 202, 347, 7, 164, 2_399, 11, 46, 4_485, 4, 2, 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, 5, 1_232, 2_864, 15_785, 14_951, 105, 5, 8_581, 1_250, 4, 2, 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]], """token_type_ids""": [[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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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], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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]]}  # noqa: E501
    # fmt: on

    self.tokenizer_integration_test_util(
        expected_encoding=lowercase_   ,				model_name="""microsoft/deberta-v2-xlarge"""   ,				revision="""ad6e42c1532ddf3a15c39246b63f5559d558b670"""   ,				)


'''simple docstring'''


from __future__ import annotations

# This is the precision for this function which can be altered.
# It is recommended for users to keep this number greater than or equal to 10.
__snake_case						  =		10

def   A_      (       SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)			->int:
  for i in range(SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						):
    if array[i] == target:
      return i
  return -1

def   A_      (       SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)			->int:
  lowercase_     =       0
  lowercase_     =       len(SCREAMING_SNAKE_CASE_						)
  while left <= right:
    if right - left < precision:
      return lin_search(SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)

    lowercase_     =       (left + right) // 3 + 1
    lowercase_     =       2 * (left + right) // 3 + 1

    if array[one_third] == target:
      return one_third
    elif array[two_third] == target:
      return two_third

    elif target < array[one_third]:
      lowercase_     =       one_third - 1
    elif array[two_third] < target:
      lowercase_     =       two_third + 1

    else:
      lowercase_     =       one_third + 1
      lowercase_     =       two_third - 1
  else:
    return -1

def   A_      (       SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)			->int:
  if left < right:
    if right - left < precision:
      return lin_search(SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)
    lowercase_     =       (left + right) // 3 + 1
    lowercase_     =       2 * (left + right) // 3 + 1

    if array[one_third] == target:
      return one_third
    elif array[two_third] == target:
      return two_third

    elif target < array[one_third]:
      return rec_ternary_search(SCREAMING_SNAKE_CASE_ ,	one_third - 1 ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)
    elif array[two_third] < target:
      return rec_ternary_search(two_third + 1 ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)
    else:
      return rec_ternary_search(one_third + 1 ,	two_third - 1 ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)
  else:
    return -1


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       __snake_case						  =		input("""Enter numbers separated by comma:\n""").strip()
       __snake_case						  =		[int(item.strip()) for item in user_input.split(""",""")]
       assert collection == sorted(collection), f"List must be ordered.\n{collection}."
       __snake_case						  =		int(input("""Enter the number to be found in the list:\n""").strip())
       __snake_case						  =		ite_ternary_search(collection, target)
       __snake_case						  =		rec_ternary_search(0, len(collection) - 1, collection, target)
       if resulta != -1:
              print(f'''Iterative search: {target} found at positions: {resulta}''')
              print(f'''Recursive search: {target} found at positions: {resulta}''')
       else:
              print("""Not found""")

