





"""simple docstring"""




from __future__ import annotations





def        a_				(							_lowercase       ,						_lowercase       ,						_lowercase   ):
						assert (
						    c % greatest_common_divisor(_lowercase       ,						_lowercase   ) == 0
						)  # greatest_common_divisor(a,b) function implemented below
						((_UpperCamelCase)   ,							(_UpperCamelCase)   ,							(_UpperCamelCase))			:					List[str]     =    extended_gcd(_lowercase       ,						_lowercase   )  # extended_gcd(a,b) function implemented below
						_UpperCamelCase			:					Optional[int]     =    c / d
						return (r * x, r * y)





def        a_				(							_lowercase       ,						_lowercase       ,						_lowercase       ,						_lowercase = 2   ):
						((_UpperCamelCase)   ,							(_UpperCamelCase))			:					Dict     =    diophantine(_lowercase       ,						_lowercase       ,						_lowercase   )  # Initial value
						_UpperCamelCase			:					Tuple     =    greatest_common_divisor(_lowercase       ,						_lowercase   )
						_UpperCamelCase			:					List[str]     =    a // d
						_UpperCamelCase			:					Union[str, Any]     =    b // d

						for i in range(_lowercase   ):
												_UpperCamelCase			:					str     =    xa + i * q
												_UpperCamelCase			:					str     =    ya - i * p
												print(_lowercase       ,						_lowercase   )





def        a_				(							_lowercase       ,						_lowercase   ):
						if a < b:
												_UpperCamelCase   ,							_UpperCamelCase			:					Dict     =    b, a

						while a % b != 0:
												_UpperCamelCase   ,							_UpperCamelCase			:					Optional[int]     =    b, a % b

						return b





def        a_				(							_lowercase       ,						_lowercase   ):
						assert a >= 0 and b >= 0

						if b == 0:
												_UpperCamelCase   ,							_UpperCamelCase   ,							_UpperCamelCase			:					Optional[Any]     =    a, 1, 0
						else:
												((_UpperCamelCase)   ,							(_UpperCamelCase)   ,							(_UpperCamelCase))			:					Optional[int]     =    extended_gcd(_lowercase       ,						a % b   )
												_UpperCamelCase			:					List[str]     =    q
												_UpperCamelCase			:					int     =    p - q * (a // b)

						assert a % d == 0 and b % d == 0
						assert d == a * x + b * y

						return (d, x, y)


if __name__ == "__main__":
						from doctest import testmod

						testmod(name="""diophantine""", verbose=True)
						testmod(name="""diophantine_all_soln""", verbose=True)
						testmod(name="""extended_gcd""", verbose=True)
						testmod(name="""greatest_common_divisor""", verbose=True)










'''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						(						)					->					List[str]:
			__lowerCAmelCase											=				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=lowercase					,	default=1					,	help="""Number of TPU cores to use (1 or 8)."""	)

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

			return parser.parse_args()





def    _lowerCAmelCase						(						)					->					Any:
			__lowerCAmelCase											=				parse_args()

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

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

