
'''simple docstring'''





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

import torch_xla.distributed.xla_multiprocessing as xmp


def 					UpperCamelCase_(     ):

							'''simple docstring'''






							snake_case_      =				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=snake_case							,    default=1							,    help="Number of TPU cores to use (1 or 8)."					)

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

							return parser.parse_args()


def 					UpperCamelCase_(     ):

							'''simple docstring'''






							snake_case_      =				parse_args()

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

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










'''simple docstring'''





def 					UpperCamelCase_(     snake_case							:	list[int]							,    snake_case							:	int					):

							'''simple docstring'''






							snake_case_      =				len(snake_case					)
							snake_case_      =				[[False] * (required_sum + 1) for _ in range(arr_len + 1					)]

							# for each arr value, a sum of zero(0) can be formed by not taking any element
							# hence True/1
							for i in range(arr_len + 1					):
														snake_case_      =				True

							# sum is not zero and set is empty then false
							for i in range(1							,    required_sum + 1					):
														snake_case_      =				False

							for i in range(1							,    arr_len + 1					):
														for j in range(1							,    required_sum + 1					):
																					if arr[i - 1] > j:
																												snake_case_      =				subset[i - 1][j]
																					if arr[i - 1] <= j:
																												snake_case_      =				subset[i - 1][j] or subset[i - 1][j - arr[i - 1]]

							return subset[arr_len][required_sum]


if __name__ == "__main__":
		import doctest

		doctest.testmod()




