





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


_UpperCAmelCase             =							get_tests_dir('fixtures/spiece.model')






@require_sentencepiece
@require_tokenizers
class        snake_case_    (		__lowercase					,unittest.TestCase						):
  A_      							=   DebertaVaTokenizer
  A_      							=   DebertaVaTokenizerFast
  A_      							=   True
  A_      							=   True






  def 				UpperCAmelCase__						(							self			:					Any      )->Tuple:






   '''simple docstring'''

   super().setUp()

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






  def 				UpperCAmelCase__						(							self			:					List[Any]       ,  _snake_case			:					Union[str, Any]      )->Optional[int]:






   '''simple docstring'''

   __lowerCAmelCase					:	List[str]      =       """this is a test"""
   __lowerCAmelCase					:	Optional[int]      =       """this is a test"""
   return input_text, output_text






  def 				UpperCAmelCase__						(							self			:					Tuple      )->Optional[int]:






   '''simple docstring'''

   __lowerCAmelCase					:	Union[str, Any]      =       """<pad>"""
   __lowerCAmelCase					:	Optional[int]      =       0

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






  def 				UpperCAmelCase__						(							self			:					Dict      )->int:






   '''simple docstring'''

   __lowerCAmelCase					:	str      =       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(_snake_case      )       ,  30001      )






  def 				UpperCAmelCase__						(							self			:					str      )->Dict:






   '''simple docstring'''

   self.assertEqual(self.get_tokenizer().vocab_size       ,  30000      )






  def 				UpperCAmelCase__						(							self			:					str      )->Optional[int]:






   '''simple docstring'''

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

   __lowerCAmelCase					:	Dict      =       DebertaVaTokenizer(_snake_case       ,  do_lower_case=_snake_case      )
   __lowerCAmelCase					:	Union[str, Any]      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	List[str]      =       DebertaVaTokenizerFast(_snake_case       ,  do_lower_case=_snake_case      )
   __lowerCAmelCase					:	Dict      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )






  @unittest.skip("""There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."""      )
  def 				UpperCAmelCase__						(							self			:					Union[str, Any]      )->Optional[int]:






   '''simple docstring'''

   pass






  @unittest.skip("""There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."""      )
  def 				UpperCAmelCase__						(							self			:					List[Any]      )->List[Any]:






   '''simple docstring'''

   pass






  def 				UpperCAmelCase__						(							self			:					Optional[int]      )->Any:






   '''simple docstring'''

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

   __lowerCAmelCase					:	Dict      =       DebertaVaTokenizer(_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	str      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	List[Any]      =       DebertaVaTokenizerFast(_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	List[Any]      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					List[Any]      )->Optional[Any]:






   '''simple docstring'''

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

   __lowerCAmelCase					:	Tuple      =       DebertaVaTokenizer(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	List[str]      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )
   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	int      =       DebertaVaTokenizerFast(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Any      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )
   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					Union[str, Any]      )->Tuple:






   '''simple docstring'''

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

   __lowerCAmelCase					:	str      =       DebertaVaTokenizer(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Dict      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	str      =       DebertaVaTokenizerFast(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Tuple      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					str      )->Dict:






   '''simple docstring'''

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

   __lowerCAmelCase					:	Union[str, Any]      =       DebertaVaTokenizer(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Any      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	Optional[Any]      =       DebertaVaTokenizerFast(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Dict      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					str      )->List[str]:






   '''simple docstring'''

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

   __lowerCAmelCase					:	Optional[Any]      =       DebertaVaTokenizer(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Tuple      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	int      =       DebertaVaTokenizerFast(_snake_case       ,  do_lower_case=_snake_case       ,  split_by_punct=_snake_case      )
   __lowerCAmelCase					:	Dict      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )

   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					Union[str, Any]      )->Union[str, Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	str      =       self.get_tokenizer()
   __lowerCAmelCase					:	List[str]      =       self.get_rust_tokenizer()

   __lowerCAmelCase					:	Any      =       """I was born in 92000, and this is falsé."""

   __lowerCAmelCase					:	str      =       tokenizer.convert_ids_to_tokens(tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )
   __lowerCAmelCase					:	Dict      =       rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )      )
   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	Dict      =       tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )
   __lowerCAmelCase					:	str      =       rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	Union[str, Any]      =       self.get_rust_tokenizer()
   __lowerCAmelCase					:	Any      =       tokenizer.encode(_snake_case      )
   __lowerCAmelCase					:	List[Any]      =       rust_tokenizer.encode(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					Union[str, Any]      )->Union[str, Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	Dict      =       """This is a test"""
   __lowerCAmelCase					:	List[Any]      =       [13, 1, 4398, 25, 21, 1289]
   __lowerCAmelCase					:	List[Any]      =       ["""▁""", """T""", """his""", """▁is""", """▁a""", """▁test"""]
   __lowerCAmelCase					:	int      =       ["""▁""", """<unk>""", """his""", """▁is""", """▁a""", """▁test"""]

   __lowerCAmelCase					:	Dict      =       DebertaVaTokenizer(_snake_case       ,  keep_accents=_snake_case      )
   __lowerCAmelCase					:	str      =       DebertaVaTokenizerFast(_snake_case       ,  keep_accents=_snake_case      )

   __lowerCAmelCase					:	Optional[Any]      =       tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	Union[str, Any]      =       tokenizer.tokenize(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	List[Any]      =       tokenizer.convert_ids_to_tokens(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	Dict      =       rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	Union[str, Any]      =       rust_tokenizer.tokenize(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	List[str]      =       rust_tokenizer.convert_ids_to_tokens(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )

   # fmt: off
   __lowerCAmelCase					:	str      =       """I was born in 92000, and this is falsé."""
   __lowerCAmelCase					:	Tuple      =       [13, 1, 23, 386, 19, 561, 3050, 15, 17, 48, 25, 8256, 18, 1, 9]
   __lowerCAmelCase					:	Optional[Any]      =       ["""▁""", """I""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """é""", """.""", ]
   __lowerCAmelCase					:	Optional[int]      =       ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """.""", ]
   # fmt: on

   __lowerCAmelCase					:	int      =       tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	Any      =       tokenizer.tokenize(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	Union[str, Any]      =       tokenizer.convert_ids_to_tokens(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )

   __lowerCAmelCase					:	Tuple      =       rust_tokenizer.encode(_snake_case       ,  add_special_tokens=_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	Dict      =       rust_tokenizer.tokenize(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )
   __lowerCAmelCase					:	Tuple      =       rust_tokenizer.convert_ids_to_tokens(_snake_case      )
   self.assertListEqual(_snake_case       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					Optional[int]      )->Any:






   '''simple docstring'''

   __lowerCAmelCase					:	List[str]      =       DebertaVaTokenizer(_snake_case      )

   __lowerCAmelCase					:	int      =       tokenizer.encode("""sequence builders"""      )
   __lowerCAmelCase					:	Any      =       tokenizer.encode("""multi-sequence build"""      )

   __lowerCAmelCase					:	Optional[Any]      =       tokenizer.build_inputs_with_special_tokens(_snake_case      )
   __lowerCAmelCase					:	Any      =       tokenizer.build_inputs_with_special_tokens(_snake_case       ,  _snake_case      )

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






  @slow
  def 				UpperCAmelCase__						(							self			:					Any      )->Tuple:






   '''simple docstring'''

   __lowerCAmelCase					:	Any      =       {"""input_ids""": [[1, 39867, 36, 19390, 486, 27, 35052, 81436, 18, 60685, 1225, 7, 35052, 81436, 18, 9367, 16899, 18, 15937, 53, 594, 773, 18, 16287, 30465, 36, 15937, 6, 41139, 38, 36979, 60763, 191, 6, 34132, 99, 6, 50538, 390, 43230, 6, 34132, 2779, 20850, 14, 699, 1072, 1194, 36, 382, 10901, 53, 7, 699, 1072, 2084, 36, 20422, 630, 53, 19, 105, 3049, 1896, 1053, 16899, 1506, 11, 37978, 4243, 7, 1237, 31869, 200, 16566, 654, 6, 35052, 81436, 7, 55630, 13593, 4, 2], [1, 26, 15011, 13, 667, 8, 1053, 18, 23611, 1237, 72356, 12820, 34, 104134, 1209, 35, 13313, 6627, 21, 202, 347, 7, 164, 2399, 11, 46, 4485, 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, 1232, 2864, 15785, 14951, 105, 5, 8581, 1250, 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, 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], [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=_snake_case       ,  model_name="""microsoft/deberta-v2-xlarge"""       ,  revision="""ad6e42c1532ddf3a15c39246b63f5559d558b670"""       ,  )






from datetime import datetime

import requests






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:str   )      ->   bytes:
 __lowerCAmelCase					:	List[Any]      =       """https://downloadgram.net/wp-json/wppress/video-downloader/video?url="""
 __lowerCAmelCase					:	Dict      =       requests.get(base_url + url   ).json()[0]["""urls"""][0]["""src"""]
 return requests.get(SCREAMING_SNAKE_CASE   ).content


if __name__ == "__main__":
      _UpperCAmelCase             =							input('Enter Video/IGTV url: ').strip()
      _UpperCAmelCase             =							f'''{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4'''
      with open(file_name, 'wb') as fp:
            fp.write(download_video(url))
      print(f'''Done. Video saved to disk as {file_name}.''')