


import math
from timeit import timeit






def 		lowercase_(  SCREAMING_SNAKE_CASE_     ):


  '''simple docstring'''

  lowerCamelCase			: str   =    0
  lowerCamelCase			: Tuple   =    abs(SCREAMING_SNAKE_CASE_     )
  while True:
    lowerCamelCase			: Dict   =    n // 10
    digits += 1
    if n == 0:
      break
  return digits






def 		lowercase_(  SCREAMING_SNAKE_CASE_     ):


  '''simple docstring'''

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






def 		lowercase_(  SCREAMING_SNAKE_CASE_     ):


  '''simple docstring'''

  return len(str(abs(SCREAMING_SNAKE_CASE_     )     )     )






def 		lowercase_(  ):


  '''simple docstring'''

  from collections.abc import Callable

  def benchmark_a_function(SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_     ) -> None:
    lowerCamelCase			: Any   =    f"""{func.__name__}({value})"""
    lowerCamelCase			: str   =    timeit(f"""__main__.{call}"""				,						setup="import __main__"     )
    print(f"""{call}: {func(SCREAMING_SNAKE_CASE_     )} -- {timing} seconds"""     )

  for value in (262144, 1125899906842624, 1267650600228229401496703205376):
    for func in (num_digits, num_digits_fast, num_digits_faster):
      benchmark_a_function(SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_     )
    print()


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   benchmark()







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

   '''simple docstring'''




   def _snake_case   (		self			):






     """simple docstring"""





     lowerCamelCase			: List[Any]   =    load_tool("image-segmentation"			)
     self.tool.setup()
     lowerCamelCase			: Optional[Any]   =    load_tool("image-segmentation"						,    remote=__A			)






   def _snake_case   (		self			):






     """simple docstring"""





     lowerCamelCase			: List[str]   =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"			)			) / "000000039769.png"			)
     lowerCamelCase			: Dict   =    self.tool(__A						,    "cat"			)
     self.assertTrue(isinstance(__A						,    Image.Image			)			)






   def _snake_case   (		self			):






     """simple docstring"""





     lowerCamelCase			: int   =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"			)			) / "000000039769.png"			)
     lowerCamelCase			: int   =    self.remote_tool(__A						,    "cat"			)
     self.assertTrue(isinstance(__A						,    Image.Image			)			)






   def _snake_case   (		self			):






     """simple docstring"""





     lowerCamelCase			: Optional[int]   =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"			)			) / "000000039769.png"			)
     lowerCamelCase			: Optional[Any]   =    self.tool(image=__A						,    label="cat"			)
     self.assertTrue(isinstance(__A						,    Image.Image			)			)






   def _snake_case   (		self			):






     """simple docstring"""





     lowerCamelCase			: str   =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"			)			) / "000000039769.png"			)
     lowerCamelCase			: Dict   =    self.remote_tool(image=__A						,    label="cat"			)
     self.assertTrue(isinstance(__A						,    Image.Image			)			)



