


'''simple docstring'''
import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp


def       a				(      )  ->     str:



					'''simple docstring'''






					UpperCamelCase__       :int							 =			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       a				(      )  ->     Union[str, Any]:



					'''simple docstring'''






					UpperCamelCase__       :str							 =			parse_args()

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

					# Patch sys.argv
					UpperCamelCase__       :List[Any]							 =			[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'''
# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
__snake_case											=					abspath(join(dirname(dirname(__file__)), '''src'''))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='''ignore''', category=FutureWarning)


def       a				(      __a       )  ->     Optional[int]:



					'''simple docstring'''






					from diffusers.utils.testing_utils import pytest_addoption_shared

					pytest_addoption_shared(__a       )







def       a				(      __a       )  ->     str:



					'''simple docstring'''






					from diffusers.utils.testing_utils import pytest_terminal_summary_main

					UpperCamelCase__       :Union[str, Any]							 =			terminalreporter.config.getoption('''--make-reports'''       )
					if make_reports:
										pytest_terminal_summary_main(__a			, id=__a       )