

"""simple docstring"""






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

import torch_xla.distributed.xla_multiprocessing as xmp





def 	lowercase      (   ) ->      int:
 __magic_name__     =      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=__UpperCamelCase      ,   default=1      ,   help='''Number of TPU cores to use (1 or 8).'''						)

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

 return parser.parse_args()





def 	lowercase      (   ) ->      Any:
 __magic_name__     =      parse_args()

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

 # Patch sys.argv
 __magic_name__     =      [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 pytest

import datasets


# Import fixture modules as plugins
__lowerCamelCase										=		["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]





def 	lowercase      (   __UpperCamelCase      ,   __UpperCamelCase						) ->      str:
 # Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit")
 for item in items:
  if any(marker in item.keywords for marker in ['''integration''', '''unit''']						):
   continue
  item.add_marker(pytest.mark.unit						)





def 	lowercase      (   __UpperCamelCase						) ->      Union[str, Any]:
 config.addinivalue_line('''markers'''      ,   '''torchaudio_latest: mark test to run with torchaudio>=0.12'''						)





@pytest.fixture(autouse=__UpperCamelCase						)
def 	lowercase      (   __UpperCamelCase      ,   __UpperCamelCase						) ->      Dict:
 # test_hf_cache_home = tmp_path_factory.mktemp("cache")  # TODO: why a cache dir per test function does not work?
 __magic_name__     =      tmp_path_factory.getbasetemp() / '''cache'''
 __magic_name__     =      test_hf_cache_home / '''datasets'''
 __magic_name__     =      test_hf_cache_home / '''metrics'''
 __magic_name__     =      test_hf_cache_home / '''modules'''
 monkeypatch.setattr('''datasets.config.HF_DATASETS_CACHE'''      ,   str(__UpperCamelCase						)						)
 monkeypatch.setattr('''datasets.config.HF_METRICS_CACHE'''      ,   str(__UpperCamelCase						)						)
 monkeypatch.setattr('''datasets.config.HF_MODULES_CACHE'''      ,   str(__UpperCamelCase						)						)
 __magic_name__     =      test_hf_datasets_cache / '''downloads'''
 monkeypatch.setattr('''datasets.config.DOWNLOADED_DATASETS_PATH'''      ,   str(__UpperCamelCase						)						)
 __magic_name__     =      test_hf_datasets_cache / '''downloads''' / '''extracted'''
 monkeypatch.setattr('''datasets.config.EXTRACTED_DATASETS_PATH'''      ,   str(__UpperCamelCase						)						)





@pytest.fixture(autouse=__UpperCamelCase      ,   scope='''session'''						)
def 	lowercase      (   ) ->      Any:
 datasets.disable_progress_bar()





@pytest.fixture(autouse=__UpperCamelCase						)
def 	lowercase      (   __UpperCamelCase						) ->      str:
 # don't take tests into account when counting downloads
 monkeypatch.setattr('''datasets.config.HF_UPDATE_DOWNLOAD_COUNTS'''      ,   __UpperCamelCase						)





@pytest.fixture
def 	lowercase      (   __UpperCamelCase						) ->      int:
 # Required to suppress RemovedIn20Warning when feature(s) are not compatible with SQLAlchemy 2.0
 # To be removed once SQLAlchemy 2.0 supported
 monkeypatch.setattr('''sqlalchemy.util.deprecations.SILENCE_UBER_WARNING'''      ,   __UpperCamelCase						)

