
import os
import unittest

from transformers.models.bertweet.tokenization_bertweet import VOCAB_FILES_NAMES, BertweetTokenizer

from ...test_tokenization_common import TokenizerTesterMixin





class   __UpperCamelCase				(    lowerCAmelCase__				,		unittest.TestCase   ):






     """simple docstring"""







     lowerCAmelCase_     =	BertweetTokenizer
     lowerCAmelCase_     =	False



     def 				UpperCAmelCase__    (							self    :    Optional[int]				):







       """simple docstring"""




       super().setUp()

       # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
       __SCREAMING_SNAKE_CASE     :					Any			=						['''I''', '''m''', '''V@@''', '''R@@''', '''r''', '''e@@''']
       __SCREAMING_SNAKE_CASE     :					str			=						dict(zip(_A      ,		range(len(_A				)				)				)				)
       __SCREAMING_SNAKE_CASE     :					int			=						['''#version: 0.2''', '''a m</w>''']
       __SCREAMING_SNAKE_CASE     :					str			=						{'''unk_token''': '''<unk>'''}

       __SCREAMING_SNAKE_CASE     :					Any			=						os.path.join(self.tmpdirname      ,		VOCAB_FILES_NAMES['''vocab_file''']				)
       __SCREAMING_SNAKE_CASE     :					str			=						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(_A				)				)



     def 				UpperCAmelCase__    (							self    :    Any      ,		**_A    :    List[Any]				):







       """simple docstring"""




       kwargs.update(self.special_tokens_map				)
       return BertweetTokenizer.from_pretrained(self.tmpdirname      ,		**_A				)



     def 				UpperCAmelCase__    (							self    :    str      ,		_A    :    Any				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					Optional[Any]			=						'''I am VinAI Research'''
       __SCREAMING_SNAKE_CASE     :					List[str]			=						'''I <unk> m V<unk> <unk> <unk> I Re<unk> e<unk> <unk> <unk> <unk>'''
       return input_text, output_text




     def 				UpperCAmelCase__    (							self    :    List[Any]				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					Any			=						BertweetTokenizer(self.vocab_file      ,		self.merges_file      ,		**self.special_tokens_map				)
       __SCREAMING_SNAKE_CASE     :					Tuple			=						'''I am VinAI Research'''
       __SCREAMING_SNAKE_CASE     :					Any			=						'''I a@@ m V@@ i@@ n@@ A@@ I R@@ e@@ s@@ e@@ a@@ r@@ c@@ h'''.split()
       __SCREAMING_SNAKE_CASE     :					List[Any]			=						tokenizer.tokenize(_A				)
       self.assertListEqual(_A      ,		_A				)

       __SCREAMING_SNAKE_CASE     :					int			=						tokens + [tokenizer.unk_token]

       __SCREAMING_SNAKE_CASE     :					Dict			=						[4, 3, 5, 6, 3, 3, 3, 4, 7, 9, 3, 9, 3, 3, 3, 3, 3]
       self.assertListEqual(tokenizer.convert_tokens_to_ids(_A				)      ,		_A				)


import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowercase_											=	"""
Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.

In March 2021, Hugging Face raised $40 million in a Series B funding round.[3]

On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]
"""





class   __UpperCamelCase				(    unittest.TestCase				,		lowerCAmelCase__   ):






     """simple docstring"""







     def 				UpperCAmelCase__    (							self    :    Optional[Any]				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					int			=						load_tool('''summarization'''				)
       self.tool.setup()
       __SCREAMING_SNAKE_CASE     :					Any			=						load_tool('''summarization'''      ,		remote=_A				)



     def 				UpperCAmelCase__    (							self    :    Tuple				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					Dict			=						self.tool(_A				)
       self.assertEqual(
           _A      ,		'''Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'''      ,		)



     def 				UpperCAmelCase__    (							self    :    List[str]				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					Optional[Any]			=						self.remote_tool(_A				)
       self.assertEqual(
           _A      ,		'''Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'''      ,		)



     def 				UpperCAmelCase__    (							self    :    List[str]				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					Dict			=						self.tool(text=_A				)
       self.assertEqual(
           _A      ,		'''Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'''      ,		)




     def 				UpperCAmelCase__    (							self    :    Optional[int]				):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE     :					str			=						self.remote_tool(text=_A				)
       self.assertEqual(
           _A      ,		'''Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'''      ,		)
