





'''simple docstring'''







import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import Mock, patch

import diffusers.utils.hub_utils





class     _UpperCAmelCase							(						unittest.TestCase   ):
		@patch("""diffusers.utils.hub_utils.get_full_repo_name"""			)
		def   lowerCamelCase__			(  self,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				"""full_repo_name"""
					with TemporaryDirectory() as tmpdir:
								# Dummy args values
								__lowerCAmelCase											=				Mock()
								__lowerCAmelCase											=				tmpdir
								__lowerCAmelCase											=				0
								__lowerCAmelCase											=				"""hub_token"""
								__lowerCAmelCase											=				"""dataset_name"""
								__lowerCAmelCase											=				0.01
								__lowerCAmelCase											=				10_00_00
								__lowerCAmelCase											=				1_00_00
								__lowerCAmelCase											=				0.01
								__lowerCAmelCase											=				0.02
								__lowerCAmelCase											=				0.03
								__lowerCAmelCase											=				0.0005
								__lowerCAmelCase											=				0.00_0001
								__lowerCAmelCase											=				1
								__lowerCAmelCase											=				10
								__lowerCAmelCase											=				0.001
								__lowerCAmelCase											=				0.1
								__lowerCAmelCase											=				0.2
								__lowerCAmelCase											=				True

								# Model card mush be rendered and saved
								diffusers.utils.hub_utils.create_model_card(__SCREAMING_SNAKE_CASE,model_name="""model_name"""			)
								self.assertTrue((Path(__SCREAMING_SNAKE_CASE			) / """README.md""").is_file()			)








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

