




'''simple docstring'''


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 			A    :
							lowercase_							=				42



class 			A    (		unittest.TestCase    ):







							def    __lowerCAmelCase			(  self       :  Tuple					)			->							Optional[Any]:


														"""simple docstring"""


														_a	     =				get_tests_dir('''fixtures/test_sentencepiece.model'''					)
														_a	     =				get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.model'''					)

														_a	     =				FakeOriginalTokenizer(vocab_file=lowerCAmelCase_					)

														with warnings.catch_warnings(record=lowerCAmelCase_					) as w:
																					_a	     =				SpmConverter(lowerCAmelCase_					)
														self.assertEqual(len(lowerCAmelCase_					)							,			0					)

														_a	     =				FakeOriginalTokenizer(vocab_file=lowerCAmelCase_					)

														with warnings.catch_warnings(record=lowerCAmelCase_					) as w:
																					_a	     =				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					)							,			)







'''simple docstring'''


import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
				from PIL import Image

class 			A    (		unittest.TestCase     ,_a    ):







							def    __lowerCAmelCase			(  self       :  Optional[int]					)			->							Optional[int]:


														"""simple docstring"""


														_a	     =				load_tool('''image-question-answering'''					)
														self.tool.setup()
														_a	     =				load_tool('''image-question-answering'''							,			remote=lowerCAmelCase_					)







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


														"""simple docstring"""


														_a	     =				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
														_a	     =				self.tool(lowerCAmelCase_							,			'''How many cats are sleeping on the couch?'''					)
														self.assertEqual(lowerCAmelCase_							,			'''2'''					)







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


														"""simple docstring"""


														_a	     =				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
														_a	     =				self.remote_tool(lowerCAmelCase_							,			'''How many cats are sleeping on the couch?'''					)
														self.assertEqual(lowerCAmelCase_							,			'''2'''					)







							def    __lowerCAmelCase			(  self       :  Dict					)			->							Tuple:


														"""simple docstring"""


														_a	     =				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
														_a	     =				self.tool(image=lowerCAmelCase_							,			question='''How many cats are sleeping on the couch?'''					)
														self.assertEqual(lowerCAmelCase_							,			'''2'''					)







							def    __lowerCAmelCase			(  self       :  Tuple					)			->							Dict:


														"""simple docstring"""


														_a	     =				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''					)					) / '''000000039769.png'''					)
														_a	     =				self.remote_tool(image=lowerCAmelCase_							,			question='''How many cats are sleeping on the couch?'''					)
														self.assertEqual(lowerCAmelCase_							,			'''2'''					)

