
'''simple docstring'''


def  __snake_case     (    _UpperCAmelCase					:       int | float | str):
   try:
      UpperCamelCase       =  float(lowerCAmelCase__)
   except ValueError:
      raise ValueError('''Please enter a valid number''')
   UpperCamelCase       =  decimal - int(lowerCAmelCase__)
   if fractional_part == 0:
      return int(lowerCAmelCase__), 1
   else:
      UpperCamelCase       =  len(str(lowerCAmelCase__).split('''.''')[1])
      UpperCamelCase       =  int(decimal * (10**number_of_frac_digits))
      UpperCamelCase       =  10**number_of_frac_digits
      UpperCamelCase     , UpperCamelCase       =  denominator, numerator
      while True:
         UpperCamelCase       =  dividend % divisor
         if remainder == 0:
            break
         UpperCamelCase     , UpperCamelCase       =  divisor, remainder
      UpperCamelCase     , UpperCamelCase       =  numerator / divisor, denominator / divisor
      return int(lowerCAmelCase__), int(lowerCAmelCase__)


if __name__ == "__main__":
   print(F'''{decimal_to_fraction(2) = }''')
   print(F'''{decimal_to_fraction(89.0) = }''')
   print(F'''{decimal_to_fraction("67") = }''')
   print(F'''{decimal_to_fraction("45.0") = }''')
   print(F'''{decimal_to_fraction(1.5) = }''')
   print(F'''{decimal_to_fraction("6.25") = }''')
   print(F'''{decimal_to_fraction("78td") = }''')







'''simple docstring'''


import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp



def  __snake_case     (    ):
   UpperCamelCase       =  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=_UpperCAmelCase,      default=1,      help='''Number of TPU cores to use (1 or 8).''')

   # positional
   parser.add_argument(
       '''training_script''',      type=_UpperCAmelCase,      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=_UpperCAmelCase)

   return parser.parse_args()



def  __snake_case     (    ):
   UpperCamelCase       =  parse_args()

   # Import training_script as a module.
   UpperCamelCase       =  Path(args.training_script)
   sys.path.append(str(script_fpath.parent.resolve()))
   UpperCamelCase       =  script_fpath.stem
   UpperCamelCase       =  importlib.import_module(_UpperCAmelCase)

   # Patch sys.argv
   UpperCamelCase       =  [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()





