
'''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     __snake_case			(    unittest.TestCase					,			_a	):




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






								'''simple docstring'''






								UpperCamelCase_     :	List[str]					     =     load_tool("""image-captioning""")
								self.tool.setup()
								UpperCamelCase_     :	List[str]					     =     load_tool("""image-captioning"""			,    remote=_SCREAMING_SNAKE_CASE)




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






								'''simple docstring'''






								UpperCamelCase_     :	Dict					     =     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO""")) / """000000039769.png""")
								UpperCamelCase_     :	Tuple					     =     self.tool(_SCREAMING_SNAKE_CASE)
								self.assertEqual(_SCREAMING_SNAKE_CASE			,    """two cats sleeping on a couch""")




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






								'''simple docstring'''






								UpperCamelCase_     :	Union[str, Any]					     =     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO""")) / """000000039769.png""")
								UpperCamelCase_     :	Optional[int]					     =     self.remote_tool(_SCREAMING_SNAKE_CASE)
								self.assertEqual(_SCREAMING_SNAKE_CASE			,    """two cats sleeping on a couch""")




		def 	_snake_case	(  self					:str)					->			str:






								'''simple docstring'''






								UpperCamelCase_     :	Optional[int]					     =     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO""")) / """000000039769.png""")
								UpperCamelCase_     :	List[str]					     =     self.tool(image=_SCREAMING_SNAKE_CASE)
								self.assertEqual(_SCREAMING_SNAKE_CASE			,    """two cats sleeping on a couch""")





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






								'''simple docstring'''






								UpperCamelCase_     :	Any					     =     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO""")) / """000000039769.png""")
								UpperCamelCase_     :	str					     =     self.remote_tool(image=_SCREAMING_SNAKE_CASE)
								self.assertEqual(_SCREAMING_SNAKE_CASE			,    """two cats sleeping on a couch""")






'''simple docstring'''


__SCREAMING_SNAKE_CASE						=      {hex(i)[2:]: i for i in range(16)}  # Use [:2] to strip off the leading '0x'
def 					__magic_name__(       UpperCAmelCase__ :       str	):
						UpperCamelCase_     :	str					     =     hex_string.strip().lower()
						if not hex_string:
												raise ValueError("""Empty string was passed to the function"""	)
						UpperCamelCase_     :	Dict					     =     hex_string[0] == """-"""
						if is_negative:
												UpperCamelCase_     :	List[str]					     =     hex_string[1:]
						if not all(char in hex_table for char in hex_string	):
												raise ValueError("""Non-hexadecimal value was passed to the function"""	)
						UpperCamelCase_     :	int					     =     0
						for char in hex_string:
												UpperCamelCase_     :	Any					     =     16 * decimal_number + hex_table[char]
						return -decimal_number if is_negative else decimal_number


if __name__ == "__main__":
	from doctest import testmod

	testmod()




