






'''simple docstring'''






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

import torch_xla.distributed.xla_multiprocessing as xmp




def        _SCREAMING_SNAKE_CASE  (				)    -> int:







   """simple docstring"""
   __snake_case				:      List[str]     							= 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        _SCREAMING_SNAKE_CASE  (				)    -> Any:







   """simple docstring"""
   __snake_case				:      Dict     							= parse_args()

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

   # Patch sys.argv
   __snake_case				:      Union[str, 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'''






import unittest

from transformers import load_tool
from transformers.utils import is_torch_available


if is_torch_available():
      import torch

from transformers.testing_utils import require_torch

from .test_tools_common import ToolTesterMixin




@require_torch
class a_    (    unittest.TestCase		,      UpperCamelCase_							):







   def     SCREAMING_SNAKE_CASE__					(self)			->      List[Any]:
      """simple docstring"""






      __snake_case				:      List[str]     							= load_tool('text-to-speech')
      self.tool.setup()







   def     SCREAMING_SNAKE_CASE__					(self)			->      Optional[Any]:
      """simple docstring"""






      torch.manual_seed(0)
      __snake_case				:      Dict     							= self.tool('hey')
      __snake_case				:      List[Any]     							= result.to_raw()
      self.assertTrue(
          torch.allclose(
              resulting_tensor[:3]					,   torch.tensor([-0.0_005_966_668_832_115_829, -0.0_003_657_640_190_795_064, -0.00_013_439_502_799_883_485])					,   ))







   def     SCREAMING_SNAKE_CASE__					(self)			->      List[Any]:
      """simple docstring"""






      torch.manual_seed(0)
      __snake_case				:      Any     							= self.tool('hey')
      __snake_case				:      Any     							= result.to_raw()
      self.assertTrue(
          torch.allclose(
              resulting_tensor[:3]					,   torch.tensor([-0.0_005_966_668_832_115_829, -0.0_003_657_640_190_795_064, -0.00_013_439_502_799_883_485])					,   ))