




'''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=_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 						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(_a     )

    # 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()





def lowerCamelCase  (   SCREAMING_SNAKE_CASE = 1  ,			SCREAMING_SNAKE_CASE = 1_000	):
    '''simple docstring'''







    __UpperCamelCase     :Union[str, Any]			  =		1
    __UpperCamelCase     :Any			  =		0

    for divide_by_number in range(SCREAMING_SNAKE_CASE  ,			digit + 1	):
        __UpperCamelCase     :list[int]			  =		[]
        __UpperCamelCase     :Optional[int]			  =		numerator
        for _ in range(1  ,			digit + 1	):
            if now_divide in has_been_divided:
                if longest_list_length < len(SCREAMING_SNAKE_CASE	):
                    __UpperCamelCase     :Optional[Any]			  =		len(SCREAMING_SNAKE_CASE	)
                    __UpperCamelCase     :int			  =		divide_by_number
            else:
                has_been_divided.append(SCREAMING_SNAKE_CASE	)
                __UpperCamelCase     :Any			  =		now_divide * 10 % divide_by_number

    return the_digit


# Tests
if __name__ == "__main__":
    import doctest

    doctest.testmod()





