
__magic_name__           =					{hex(i)[2:]: i for i in range(16)}  # Use [:2] to strip off the leading '0x'





def 		SCREAMING_SNAKE_CASE__      ( __lowerCAmelCase							):
    snake_case__  =			hex_string.strip().lower()
    if not hex_string:
        raise ValueError("Empty string was passed to the function"							)
    snake_case__  =			hex_string[0] == "-"
    if is_negative:
        snake_case__  =			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"							)
    snake_case__  =			0
    for char in hex_string:
        snake_case__  =			16 * decimal_number + hex_table[char]
    return -decimal_number if is_negative else decimal_number


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

     testmod()





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    _SCREAMING_SNAKE_CASE					( unittest.TestCase    ,   __UpperCamelCase	):
      def A_     (     self	):
          snake_case__  =			load_tool("image-captioning"	)
          self.tool.setup()
          snake_case__  =			load_tool("image-captioning"						,		remote=lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.tool(lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)
      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.remote_tool(lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)
      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.tool(image=lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)



      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.remote_tool(image=lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)



