code: def parse_args():
      parser = argparse.ArgumentParser(
          description="Run the PyTorch unit test suite",
          epilog="where TESTS is any of: {}".format(", ".join(TESTS)),
          formatter_class=argparse.RawTextHelpFormatter,
          parents=[common_parser],
      )
      parser.add_argument(
          "-v",
          "--verbose",
          action="count",
          default=0,
          help="Print verbose information and test-by-test results",
      )
      parser.add_argument(
          "--jit",
          "--jit",
          action="store_true",
          help="run all jit tests",
      )
      parser.add_argument(
          "--distributed-tests",
          "--distributed-tests",
          action="store_true",
          help="Run all distributed tests",
      )
      parser.add_argument(
          "--functorch",
          "--functorch",
          action="store_true",
          help=(
              "If this flag is present, we will only run functorch tests. "
              "If this flag is not present, we will run all tests "
              "(including functorch tests)."
          ),
      )
      parser.add_argument(
          "--mps",
          "--mps",
          action="store_true",
          help=(
              "If this flag is present, we will only run test_mps and test_metal"
          ),
      )
      parser.add_argument(
          "--cpp",
          "--cpp",
          action="store_true",
          help=("If this flag is present, we will only run C++ tests"),
      )
      parser.add_argument(
          "-core",
          "--core",
          action="store_true",
          help="Only run core tests, or tests that validate PyTorch's ops, modules,"
          "and autograd. They are defined by CORE_TEST_LIST.",
      )
      parser.add_argument(
          "--onnx",
          "--onnx",
          action="store_true",
          help=(
              "Only run ONNX tests, or tests that validate PyTorch's ONNX export. "
              "If this flag is not present, we will exclude ONNX tests."
          ),
      )
      parser.add_argument(
          "-k",
          "--pytest-k-expr",
          default="",
          help="Pass to pytest as its -k expr argument",
      )
      parser.add_argument(
          "-c",
          "--coverage",
          action="store_true",
          help="enable coverage",
          default=PYTORCH_COLLECT_COVERAGE,
      )
      parser.add_argument(
          "-i",
          "--include",
          nargs="+",
          choices=TestChoices(TESTS),
          default=TESTS,
          metavar="TESTS",
          help="select a set of tests to include (defaults to ALL tests)."
          " tests must be a part of the TESTS list defined in run_test.py",
      )
      parser.add_argument(
          "-x",
          "--exclude",
          nargs="+",
          choices=TESTS,
          metavar="TESTS",
          default=[],
          help="select a set of tests to exclude",
      )
      parser.add_argument(
          "--ignore-win-blocklist",
          action="store_true",
          help="always run blocklisted windows tests",
      )
      # NS: Disable target determination until it can be made more reliable
      # parser.add_argument(
      #     "--determine-from",
      #     help="File of affected source filenames to determine which tests to run.",
      # )
      parser.add_argument(
          "--continue-through-error",
          "--keep-going",
          action="store_true",
          help="Runs the full test suite despite one of the tests failing",
          default=strtobool(
              os.environ.get("CONTINUE_THROUGH_ERROR", "False")
          ),
      )
      parser.add_argument(
          "additional_unittest_args",
          nargs="*",
          help="additional arguments passed through to unittest, e.g., "
          "python run_test.py -i sparse -- TestSparse.test_factory_size_check",
      )
      parser.add_argument(
          "--shard",
          nargs=2,
          type=int,
          help="runs a shard of the tests (taking into account other selections), e.g., "
          "--shard 2 3 will break up the selected tests into 3 shards and run the tests "
          "in the 2nd shard (the first number should not exceed the second)",
      )
      parser.add_argument(
          "--exclude-jit-executor",
          action="store_true",
          help="exclude tests that are run for a specific jit config",
      )
      parser.add_argument(
          "--exclude-distributed-tests",
          action="store_true",
          help="exclude distributed tests",
      )
      parser.add_argument(
          "--dry-run",
          action="store_true",
          help="Only list the test that will run.",
      )
      parser.add_argument(
          "--xdoctest-command",
          default="all",
          help=(
              "Control the specific doctest action. "
              "Use 'list' to simply parse doctests and check syntax. "
              "Use 'all' to execute all doctests or specify a specific "
              "doctest to run"
          ),
      )
      parser.add_argument(
          "--no-translation-validation",
          action="store_false",
          help="Run tests without translation validation.",
      )
  
      group = parser.add_mutually_exclusive_group()
      group.add_argument(
          "--dynamo",
          action="store_true",
          help="Run tests with TorchDynamo+EagerBackend turned on",
      )
      group.add_argument(
          "--inductor",
          action="store_true",
          help="Run tests with TorchInductor turned on",
      )
  
      return parser.parse_args()
  
imports: import argparse
  import copy
  import glob
  import json
  import os
  import pathlib
  import re
  import shutil
  import signal
  import subprocess
  import sys
  import tempfile
  import time
  from collections import defaultdict
  from contextlib import ExitStack
  from datetime import datetime
  from typing import Any, cast, Dict, List, NamedTuple, Optional, Sequence, Tuple, Union
  import pkg_resources
  import torch
  import torch.distributed
  from torch.multiprocessing import current_process, get_context
  from torch.testing._internal.common_utils import FILE_SCHEMA, get_report_path, IS_CI, parser, retry_shell, set_cwd, shell, TEST_WITH_ASAN, TEST_WITH_ROCM, TEST_WITH_SLOW_GRADCHECK
  from tools.stats.import_test_stats import ADDITIONAL_CI_FILES_FOLDER, TEST_CLASS_TIMES_FILE, TEST_TIMES_FILE
  from tools.stats.upload_metrics import add_global_metric, emit_metric
  from tools.testing.target_determination.determinator import AggregatedHeuristics, get_prediction_confidences, get_test_prioritizations
  from tools.testing.test_run import TestRun
  from tools.testing.test_selections import calculate_shards, get_test_case_configs, NUM_PROCS, ShardedTest, THRESHOLD
label_desc: Use image node_id 18 for calling a global function with example usage: parse_args() and returns: parser