code: '''simple docstring'''
  
  
  
  
  
  import importlib
  import sys
  from argparse import REMAINDER, ArgumentParser
  from pathlib import Path
  
  import torch_xla.distributed.xla_multiprocessing as xmp
  
  
  def 					__lowerCAmelCase			(  ):
  
  
  
  							"""simple docstring"""
  
  
  							_lowercase				=	ArgumentParser(
  							    description=(
  							        """PyTorch TPU distributed training launch helper utility that will spawn up multiple distributed processes"""
  							    )					)
  
  							# Optional arguments for the launch helper
  							parser.add_argument("""--num_cores""" ,type=_A ,default=1 ,help="""Number of TPU cores to use (1 or 8)."""					)
  
  							# positional
  							parser.add_argument(
  							    """training_script""" ,type=_A ,help=(
  							        """The full path to the single TPU training """
  							        """program/script to be launched in parallel, """
  							        """followed by all the arguments for the """
  							        """training script"""
  							    ) ,)
  
  							# rest from the training program
  							parser.add_argument("""training_script_args""" ,nargs=_A					)
  
  							return parser.parse_args()
  
  
  def 					__lowerCAmelCase			(  ):
  
  
  
  							"""simple docstring"""
  
  
  							_lowercase				=	parse_args()
  
  							# Import training_script as a module.
  							_lowercase				=	Path(args.training_script					)
  							sys.path.append(str(script_fpath.parent.resolve()					)					)
  							_lowercase				=	script_fpath.stem
  							_lowercase				=	importlib.import_module(_A					)
  
  							# Patch sys.argv
  							_lowercase				=	[args.training_script] + args.training_script_args + ["""--tpu_num_cores""", str(args.num_cores					)]
  
  							xmp.spawn(mod._mp_fn ,args=() ,nprocs=args.num_cores					)
  
  
  if __name__ == "__main__":
  				main()
  
  
  
style_context: import math
  from timeit import timeit
  
  
  def 					__lowerCAmelCase			(  _A					):
  
  
  
  							"""simple docstring"""
  
  
  							_lowercase				=	0
  							_lowercase				=	abs(_A					)
  							while True:
  														_lowercase				=	n // 10
  														digits += 1
  														if n == 0:
  																					break
  							return digits
  
  
  def 					__lowerCAmelCase			(  _A					):
  
  
  
  							"""simple docstring"""
  
  
  							return 1 if n == 0 else math.floor(math.log(abs(_A					) ,10					) + 1					)
  
  
  def 					__lowerCAmelCase			(  _A					):
  
  
  
  							"""simple docstring"""
  
  
  							return len(str(abs(_A					)					)					)
  
  
  def 					__lowerCAmelCase			(  ):
  
  
  
  							"""simple docstring"""
  
  
  							from collections.abc import Callable
  
  							def benchmark_a_function(_A ,_A					) -> None:
  														_lowercase				=	f'''{func.__name__}({value})'''
  														_lowercase				=	timeit(f'''__main__.{call}''' ,setup="""import __main__"""					)
  														print(f'''{call}: {func(_A					)} -- {timing} seconds'''					)
  
  							for value in (262_144, 1_125_899_906_842_624, 1_267_650_600_228_229_401_496_703_205_376):
  														for func in (num_digits, num_digits_fast, num_digits_faster):
  																					benchmark_a_function(_A ,_A					)
  														print()
  
  
  if __name__ == "__main__":
  				import doctest
  
  				doctest.testmod()
  				benchmark()
  
  
  