






"""simple docstring"""





import unittest

from datasets import load_dataset

from transformers import load_tool

from .test_tools_common import ToolTesterMixin







class 						_a  (		unittest.TestCase							,	lowercase_       ):





   '''simple docstring'''






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




          '''simple docstring'''




          lowercase__:							Optional[Any]         =     load_tool("document-question-answering")
          self.tool.setup()
          lowercase__:							List[str]         =     load_tool("document-question-answering"					, remote=UpperCAmelCase_)





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




          '''simple docstring'''




          lowercase__:							str         =     load_dataset("hf-internal-testing/example-documents"					, split="test")
          lowercase__:							Any         =     dataset[0]["image"]

          lowercase__:							int         =     self.tool(UpperCAmelCase_					, "When is the coffee break?")
          self.assertEqual(UpperCAmelCase_					, "11-14 to 11:39 a.m.")





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




          '''simple docstring'''




          lowercase__:							Union[str, Any]         =     load_dataset("hf-internal-testing/example-documents"					, split="test")
          lowercase__:							Any         =     dataset[0]["image"]

          lowercase__:							Tuple         =     self.remote_tool(UpperCAmelCase_					, "When is the coffee break?")
          self.assertEqual(UpperCAmelCase_					, "11-14 to 11:39 a.m.")





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




          '''simple docstring'''




          lowercase__:							Dict         =     load_dataset("hf-internal-testing/example-documents"					, split="test")
          lowercase__:							Tuple         =     dataset[0]["image"]

          self.tool(document=UpperCAmelCase_					, question="When is the coffee break?")





   def __lowercase							(       self)			->   Any:




          '''simple docstring'''




          lowercase__:							Optional[int]         =     load_dataset("hf-internal-testing/example-documents"					, split="test")
          lowercase__:							List[str]         =     dataset[0]["image"]

          lowercase__:							Any         =     self.remote_tool(document=UpperCAmelCase_					, question="When is the coffee break?")
          self.assertEqual(UpperCAmelCase_					, "11-14 to 11:39 a.m.")










import unittest
import warnings
from dataclasses import dataclass

from transformers.convert_slow_tokenizer import SpmConverter
from transformers.testing_utils import get_tests_dir

@dataclass
class    __magic_name__						:
     A:		str



class    __magic_name__						(  unittest.TestCase):


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





      '''simple docstring'''






      UpperCamelCase__       :     Optional[Any] 							= get_tests_dir('''fixtures/test_sentencepiece.model'''      )
      UpperCamelCase__       :     Any 							= get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.model'''      )

      UpperCamelCase__       :     List[str] 							= FakeOriginalTokenizer(vocab_file=lowerCamelCase__      )

      with warnings.catch_warnings(record=lowerCamelCase__      ) as w:
       UpperCamelCase__       :     Optional[int] 							= SpmConverter(lowerCamelCase__      )
      self.assertEqual(len(lowerCamelCase__      )				,						0      )

      UpperCamelCase__       :     Tuple 							= FakeOriginalTokenizer(vocab_file=lowerCamelCase__      )

      with warnings.catch_warnings(record=lowerCamelCase__      ) as w:
       UpperCamelCase__       :     str 							= SpmConverter(lowerCamelCase__      )
      self.assertEqual(len(lowerCamelCase__      )				,						1      )

      self.assertIn(
          '''The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option'''
          ''' which is not implemented in the fast tokenizers.'''				,						str(w[0].message      )				,						)


