





'''simple docstring'''


import os
import unittest

from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer

from ...test_tokenization_common import TokenizerTesterMixin
class 				a_       (    _lowerCAmelCase     ,						unittest.TestCase							):
     __A								=      PhobertTokenizer
     __A								=      False





     def 							lowercase__				(			self		: Dict						):





        """simple docstring"""




        super().setUp()

        # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
        lowercase_      :Tuple         =			["T@@", "i", "I", "R@@", "r", "e@@"]
        lowercase_      :Optional[Any]         =			dict(zip(lowercase     ,				range(len(lowercase						)						)						)						)
        lowercase_      :int         =			["#version: 0.2", "l à</w>"]
        lowercase_      :Dict         =			{"unk_token": "<unk>"}

        lowercase_      :Dict         =			os.path.join(self.tmpdirname     ,				VOCAB_FILES_NAMES["vocab_file"]						)
        lowercase_      :Optional[int]         =			os.path.join(self.tmpdirname     ,				VOCAB_FILES_NAMES["merges_file"]						)

        with open(self.vocab_file     ,				"w"     ,				encoding="utf-8"						) as fp:
           for token in vocab_tokens:
              fp.write(F'{token} {vocab_tokens[token]}\n'						)
        with open(self.merges_file     ,				"w"     ,				encoding="utf-8"						) as fp:
           fp.write("\n".join(lowercase						)						)





     def 							lowercase__				(			self		: int     ,				**lowercase		: Dict						):





        """simple docstring"""




        kwargs.update(self.special_tokens_map						)
        return PhobertTokenizer.from_pretrained(self.tmpdirname     ,				**lowercase						)





     def 							lowercase__				(			self		: List[Any]     ,				lowercase		: Tuple						):





        """simple docstring"""




        lowercase_      :Dict         =			"Tôi là VinAI Research"
        lowercase_      :Union[str, Any]         =			"T<unk> i <unk> <unk> <unk> <unk> <unk> <unk> I Re<unk> e<unk> <unk> <unk> <unk>"
        return input_text, output_text







     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        lowercase_      :Optional[int]         =			PhobertTokenizer(self.vocab_file     ,				self.merges_file     ,				**self.special_tokens_map						)
        lowercase_      :Tuple         =			"Tôi là VinAI Research"
        lowercase_      :Optional[Any]         =			"T@@ ô@@ i l@@ à V@@ i@@ n@@ A@@ I R@@ e@@ s@@ e@@ a@@ r@@ c@@ h".split()
        lowercase_      :Optional[int]         =			tokenizer.tokenize(lowercase						)
        print(lowercase						)
        self.assertListEqual(lowercase     ,				lowercase						)

        lowercase_      :Union[str, Any]         =			tokens + [tokenizer.unk_token]

        lowercase_      :List[Any]         =			[4, 3, 5, 3, 3, 3, 3, 3, 3, 6, 7, 9, 3, 9, 3, 3, 3, 3, 3]
        self.assertListEqual(tokenizer.convert_tokens_to_ids(lowercase						)     ,				lowercase						)









'''simple docstring'''


def 							UpperCAmelCase_  (						__lowerCamelCase : dict			):
   lowercase_      :set[int]         =			set()
   # To detect a back edge, keep track of vertices currently in the recursion stack
   lowercase_      :set[int]         =			set()
   return any(
       node not in visited and depth_first_search(__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			)
       for node in graph			)
def 							UpperCAmelCase_  (						__lowerCamelCase : dict     ,__lowerCamelCase : int     ,__lowerCamelCase : set     ,__lowerCamelCase : set			):
   visited.add(__lowerCamelCase			)
   rec_stk.add(__lowerCamelCase			)

   for node in graph[vertex]:
      if node not in visited:
         if depth_first_search(__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			):
            return True
      elif node in rec_stk:
         return True

    # The node needs to be removed from recursion stack before function ends
   rec_stk.remove(__lowerCamelCase			)
   return False


if __name__ == "__main__":
 from doctest import testmod

 testmod()


