





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

import torch_xla.distributed.xla_multiprocessing as xmp




def 		lowerCAmelCase_    (  )      ->	str:
    UpperCamelCase__							:				Dict          =      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 		lowerCAmelCase_    (  )      ->	Optional[Any]:
    UpperCamelCase__							:				Tuple          =      parse_args()

    # Import training_script as a module.
    UpperCamelCase__							:				Optional[int]          =      Path(args.training_script      )
    sys.path.append(str(script_fpath.parent.resolve()      )      )
    UpperCamelCase__							:				Optional[Any]          =      script_fpath.stem
    UpperCamelCase__							:				Any          =      importlib.import_module(__UpperCAmelCase      )

    # Patch sys.argv
    UpperCamelCase__							:				List[str]          =      [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()








from math import factorial




def 		lowerCAmelCase_    (  __UpperCAmelCase:			int		,   __UpperCAmelCase:			int      )      ->	int:

    # If either of the conditions are true, the function is being asked
    # to calculate a factorial of a negative number, which is not possible
    if n < k or k < 0:
        raise ValueError('''Please enter positive integers for n and k where n >= k'''      )
    return factorial(__UpperCAmelCase      ) // (factorial(__UpperCAmelCase      ) * factorial(n - k      ))


if __name__ == "__main__":
  print(
      'The number of five-card hands possible from a standard',
      F'''fifty-two card deck is: {combinations(52, 5)}\n''',
  )

  print(
      'If a class of 40 students must be arranged into groups of',
      F'''4 for group projects, there are {combinations(40, 4)} ways''',
      'to arrange them.\n',
  )

  print(
      'If 10 teams are competing in a Formula One race, there',
      F'''are {combinations(10, 3)} ways that first, second and''',
      'third place can be awarded.',
  )

