


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

import torch_xla.distributed.xla_multiprocessing as xmp
def       UpperCAmelCase__						():



     """simple docstring"""






     snake_case					=    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=lowerCAmelCase__							,default=1							,help='''Number of TPU cores to use (1 or 8).'''    )

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

     return parser.parse_args()
def       UpperCAmelCase__						():



     """simple docstring"""






     snake_case					=    parse_args()

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

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








# 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.
_SCREAMING_SNAKE_CASE      :			Union[str, Any]      				=   abspath(join(dirname(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       UpperCAmelCase__						(UpperCamelCase_    ):



     """simple docstring"""






     from transformers.testing_utils import pytest_addoption_shared

     pytest_addoption_shared(UpperCamelCase_    )

def       UpperCAmelCase__						(UpperCamelCase_    ):



     """simple docstring"""






     from transformers.testing_utils import pytest_terminal_summary_main

     snake_case					=    terminalreporter.config.getoption('''--make-reports'''    )
     if make_reports:
          pytest_terminal_summary_main(UpperCamelCase_							,id=UpperCamelCase_    )




