





'''simple docstring'''




import math
from timeit import timeit



def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							str						=	0
		SCREAMING_SNAKE_CASE				:							Optional[Any]						=	abs(lowerCamelCase_					)
		while True:
				SCREAMING_SNAKE_CASE				:							List[Any]						=	n // 10
				digits += 1
				if n == 0:
						break
		return digits



def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		return 1 if n == 0 else math.floor(math.log(abs(lowerCamelCase_					)	,	10					) + 1					)



def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		return len(str(abs(lowerCamelCase_					)					)					)



def 						__A						(       ):


		"""simple docstring"""



		from collections.abc import Callable

		def benchmark_a_function(lowerCamelCase_	,	lowerCamelCase_					) -> None:
				SCREAMING_SNAKE_CASE				:							str						=	f'''{func.__name__}({value})'''
				SCREAMING_SNAKE_CASE				:							List[str]						=	timeit(f'''__main__.{call}'''	,	setup="""import __main__"""					)
				print(f'''{call}: {func(lowerCamelCase_					)} -- {timing} seconds'''					)

		for value in (26_21_44, 11_25_89_99_06_84_26_24, 1_26_76_50_60_02_28_22_94_01_49_67_03_20_53_76):
				for func in (num_digits, num_digits_fast, num_digits_faster):
						benchmark_a_function(lowerCamelCase_	,	lowerCamelCase_					)
				print()


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							benchmark()










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




					"""simple docstring"""


					def lowerCamelCase_	(		self							:	Any		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							int						=	load_tool("""image-captioning"""		)
							self.tool.setup()
							SCREAMING_SNAKE_CASE				:							str						=	load_tool("""image-captioning"""     ,		remote=lowerCamelCase_		)


					def lowerCamelCase_	(		self							:	List[Any]		):

							'''simple docstring'''



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


					def lowerCamelCase_	(		self							:	str		):

							'''simple docstring'''



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


					def lowerCamelCase_	(		self							:	List[Any]		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							str						=	self.tool(image=lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)



					def lowerCamelCase_	(		self							:	Any		):

							'''simple docstring'''



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



