



import math
from timeit import timeit
def 	UpperCamelCase			(     snake_case__ :					int			)			->  int:
   UpperCamelCase					:						Tuple					=			0
   UpperCamelCase					:						Union[str, Any]					=			abs(snake_case__			)
   while True:
      UpperCamelCase					:						Dict					=			n // 10
      digits += 1
      if n == 0:
         break
   return digits
def 	UpperCamelCase			(     snake_case__ :					int			)			->  int:
   return 1 if n == 0 else math.floor(math.log(abs(snake_case__			) ,  10			) + 1			)
def 	UpperCamelCase			(     snake_case__ :					int			)			->  int:
   return len(str(abs(snake_case__			)			)			)
def 	UpperCamelCase			(     )			->  None:
   from collections.abc import Callable

   def benchmark_a_function(snake_case__ :					Callable ,  snake_case__ :					int			) -> None:
      UpperCamelCase					:						Any					=			F"""{func.__name__}({value})"""
      UpperCamelCase					:						List[str]					=			timeit(F"""__main__.{call}""" ,  setup='import __main__'			)
      print(F"""{call}: {func(snake_case__			)} -- {timing} seconds"""			)

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


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()








import json
import logging
import os
import subprocess
from argparse import ArgumentParser


__UpperCAmelCase      = logging.getLogger(__name__)
def 	UpperCamelCase			(     )			->  List[str]:
   UpperCamelCase					:						Union[str, Any]					=			ArgumentParser()
   UpperCamelCase			,  UpperCamelCase					:						Optional[int]					=			parser.parse_known_args()
   for arg in unknown:
      if arg.startswith(('-', '--')			):
         parser.add_argument(arg.split('='			)[0]			)

   return parser.parse_args()
def 	UpperCamelCase			(     )			->  Optional[Any]:
   UpperCamelCase					:						int					=			parse_args()
   UpperCamelCase					:						Dict					=			8888
   UpperCamelCase					:						Union[str, Any]					=			int(os.environ['SM_NUM_GPUS']			)
   UpperCamelCase					:						Optional[Any]					=			json.loads(os.environ['SM_HOSTS']			)
   UpperCamelCase					:						Dict					=			len(snake_case__			)
   UpperCamelCase					:						int					=			os.environ['SM_CURRENT_HOST']
   UpperCamelCase					:						List[str]					=			hosts.index(snake_case__			)
   UpperCamelCase					:						Optional[Any]					=			'INFO'

   if num_nodes > 1:
      UpperCamelCase					:						List[Any]					=			F"""python -m torch.distributed.launch \
                --nnodes={num_nodes}  \
                --node_rank={rank}  \
                --nproc_per_node={num_gpus}  \
                --master_addr={hosts[0]}  \
                --master_port={port} \
                ./run_glue.py \
                {"".join(["nested fstring" for parameter,value in args.__dict__.items()]			)}"""
   else:
      UpperCamelCase					:						Any					=			F"""python -m torch.distributed.launch \
            --nproc_per_node={num_gpus}  \
            ./run_glue.py \
            {"".join(["nested fstring" for parameter,value in args.__dict__.items()]			)}"""
   try:
      subprocess.run(snake_case__ ,  shell=snake_case__			)
   except Exception as e:
      logger.info(snake_case__			)


if __name__ == "__main__":
    main()



