
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 					__lowercase		(					unittest.TestCase							,       UpperCAmelCase_       ):


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





									'''simple docstring'''
									A_       	=  load_tool('''image-captioning'''						)
									self.tool.setup()
									A_       	=  load_tool('''image-captioning'''       ,       remote=__UpperCamelCase						)


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





									'''simple docstring'''
									A_       	=  Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
									A_       	=  self.tool(__UpperCamelCase						)
									self.assertEqual(__UpperCamelCase       ,       '''two cats sleeping on a couch'''						)


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





									'''simple docstring'''
									A_       	=  Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
									A_       	=  self.remote_tool(__UpperCamelCase						)
									self.assertEqual(__UpperCamelCase       ,       '''two cats sleeping on a couch'''						)


					def        lowerCAmelCase_    (	self						)		->							Any:





									'''simple docstring'''
									A_       	=  Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
									A_       	=  self.tool(image=__UpperCamelCase						)
									self.assertEqual(__UpperCamelCase       ,       '''two cats sleeping on a couch'''						)


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





									'''simple docstring'''
									A_       	=  Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
									A_       	=  self.remote_tool(image=__UpperCamelCase						)
									self.assertEqual(__UpperCamelCase       ,       '''two cats sleeping on a couch'''						)

from collections import namedtuple

SCREAMING_SNAKE_CASE   :		Any					 =       namedtuple("from_to", "from_ to")

SCREAMING_SNAKE_CASE   :		str					 =       {
    "atm": from_to(1, 1),
    "pascal": from_to(0.0000098, 10_1325),
    "bar": from_to(0.986923, 1.01325),
    "kilopascal": from_to(0.00986923, 101.325),
    "megapascal": from_to(9.86923, 0.101325),
    "psi": from_to(0.068046, 14.6959),
    "inHg": from_to(0.0334211, 29.9213),
    "torr": from_to(0.00131579, 760),
}



def        lowerCamelCase_  (   __UpperCamelCase ,						__UpperCamelCase ,						__UpperCamelCase     ):
				if from_type not in PRESSURE_CONVERSION:
								raise ValueError(
								    F"Invalid 'from_type' value: {from_type!r}  Supported values are:\n"
								    + ''', '''.join(__UpperCamelCase     )     )
				if to_type not in PRESSURE_CONVERSION:
								raise ValueError(
								    F"Invalid 'to_type' value: {to_type!r}.  Supported values are:\n"
								    + ''', '''.join(__UpperCamelCase     )     )
				return (
				    value * PRESSURE_CONVERSION[from_type].from_ * PRESSURE_CONVERSION[to_type].to
				)


if __name__ == "__main__":
						import doctest

						doctest.testmod()