
"""simple docstring"""




import os
import unittest

from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer
from transformers.testing_utils import get_tests_dir

from ...test_tokenization_common import TokenizerTesterMixin


UpperCAmelCase__      :    Any    							= get_tests_dir('fixtures/test_sentencepiece_bpe.model')



class 	lowerCAmelCase_						(a__ ,					unittest.TestCase  ):


				"""simple docstring"""



				__UpperCamelCase      :						Optional[Any]					       =   BartphoTokenizer
				__UpperCamelCase      :						int					       =   False
				__UpperCamelCase      :						Optional[Any]					       =   True



				def 	__magic_name__    (self    )					->		Optional[Any]:



											"""simple docstring"""




											super().setUp()

											SCREAMING_SNAKE_CASE__						:       List[str]           =   ["""▁This""", """▁is""", """▁a""", """▁t""", """est"""]
											SCREAMING_SNAKE_CASE__						:       Tuple           =   dict(zip(SCREAMING_SNAKE_CASE__   ,       range(len(SCREAMING_SNAKE_CASE__    )    )    )    )
											SCREAMING_SNAKE_CASE__						:       Dict           =   {"""unk_token""": """<unk>"""}

											SCREAMING_SNAKE_CASE__						:       Dict           =   os.path.join(self.tmpdirname   ,       VOCAB_FILES_NAMES["""monolingual_vocab_file"""]    )
											with open(self.monolingual_vocab_file   ,       """w"""   ,       encoding="""utf-8"""    ) as fp:
																		for token in vocab_tokens:
																									fp.write(F'''{token} {vocab_tokens[token]}\n'''    )

											SCREAMING_SNAKE_CASE__						:       Tuple           =   BartphoTokenizer(SCREAMING_SNAKE_CASE__   ,       self.monolingual_vocab_file   ,       **self.special_tokens_map    )
											tokenizer.save_pretrained(self.tmpdirname    )



				def 	__magic_name__    (self   ,       **SCREAMING_SNAKE_CASE__    )					->		str:



											"""simple docstring"""




											kwargs.update(self.special_tokens_map    )
											return BartphoTokenizer.from_pretrained(self.tmpdirname   ,       **SCREAMING_SNAKE_CASE__    )



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__    )					->		Tuple:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       List[Any]           =   """This is a là test"""
											SCREAMING_SNAKE_CASE__						:       Dict           =   """This is a<unk><unk> test"""
											return input_text, output_text



				def 	__magic_name__    (self    )					->		Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       str           =   BartphoTokenizer(SCREAMING_SNAKE_CASE__   ,       self.monolingual_vocab_file   ,       **self.special_tokens_map    )
											SCREAMING_SNAKE_CASE__						:       Optional[Any]           =   """This is a là test"""
											SCREAMING_SNAKE_CASE__						:       Any           =   """▁This ▁is ▁a ▁l à ▁t est""".split()
											SCREAMING_SNAKE_CASE__						:       Union[str, Any]           =   tokenizer.tokenize(SCREAMING_SNAKE_CASE__    )
											self.assertListEqual(SCREAMING_SNAKE_CASE__   ,       SCREAMING_SNAKE_CASE__    )

											SCREAMING_SNAKE_CASE__						:       str           =   tokens + [tokenizer.unk_token]
											SCREAMING_SNAKE_CASE__						:       int           =   [4, 5, 6, 3, 3, 7, 8, 3]
											self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE__    )   ,       SCREAMING_SNAKE_CASE__    )






"""simple docstring"""




def lowercase_  (   _snake_case   ,_snake_case						):
							return 1 if input_a == input_a else 0

def lowercase_  (   ):
							assert xnor_gate(0   ,0						) == 1
							assert xnor_gate(0   ,1						) == 0
							assert xnor_gate(1   ,0						) == 0
							assert xnor_gate(1   ,1						) == 1


if __name__ == "__main__":
					print(xnor_gate(0, 0))
					print(xnor_gate(0, 1))
					print(xnor_gate(1, 0))
					print(xnor_gate(1, 1))




