


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				,       UpperCamelCase__					):




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


										"""simple docstring"""





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




						def 							__UpperCamelCase			(    self   : Dict					)							->       Optional[Any]:


										"""simple docstring"""





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




						def 							__UpperCamelCase			(    self   : List[str]					)							->       List[Any]:


										"""simple docstring"""





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




						def 							__UpperCamelCase			(    self   : Dict					)							->       List[Any]:


										"""simple docstring"""





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




						def 							__UpperCamelCase			(    self   : Tuple					)							->       Tuple:


										"""simple docstring"""





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



from ..utils import DummyObject, requires_backends

class   A__							(						metaclass=UpperCamelCase__					):
						UpperCAmelCase     =  ["torch", "librosa"]




						def __init__(    self   : Dict			,      *_a   : Union[str, Any]			,      **_a   : List[str]					)							->       Optional[int]:


										"""simple docstring"""





										requires_backends(self			,      ['''torch''', '''librosa''']					)




						@classmethod
						def 							__UpperCamelCase			(    cls   : Dict			,      *_a   : Tuple			,      **_a   : Tuple					)							->       Optional[int]:


										"""simple docstring"""





										requires_backends(cls			,      ['''torch''', '''librosa''']					)




						@classmethod
						def 							__UpperCamelCase			(    cls   : List[Any]			,      *_a   : Any			,      **_a   : List[str]					)							->       Dict:


										"""simple docstring"""





										requires_backends(cls			,      ['''torch''', '''librosa''']					)

class   A__							(						metaclass=UpperCamelCase__					):
						UpperCAmelCase     =  ["torch", "librosa"]




						def __init__(    self   : List[Any]			,      *_a   : int			,      **_a   : int					)							->       Optional[Any]:


										"""simple docstring"""





										requires_backends(self			,      ['''torch''', '''librosa''']					)




						@classmethod
						def 							__UpperCamelCase			(    cls   : str			,      *_a   : Dict			,      **_a   : Optional[Any]					)							->       Union[str, Any]:


										"""simple docstring"""





										requires_backends(cls			,      ['''torch''', '''librosa''']					)




						@classmethod
						def 							__UpperCamelCase			(    cls   : List[str]			,      *_a   : Optional[int]			,      **_a   : Union[str, Any]					)							->       Optional[Any]:


										"""simple docstring"""





										requires_backends(cls			,      ['''torch''', '''librosa''']					)