code: def get_selected_tests(options) -> List[str]:
      selected_tests = options.include
  
      # filter if there's JIT only and distributed only test options
      if options.jit:
          selected_tests = list(
              filter(
                  lambda test_name: "jit" in test_name, selected_tests
              )
          )
  
      if options.distributed_tests:
          selected_tests = list(
              filter(
                  lambda test_name: test_name in DISTRIBUTED_TESTS,
                  selected_tests,
              )
          )
  
      # Filter to only run core tests when --core option is specified
      if options.core:
          selected_tests = list(
              filter(
                  lambda test_name: test_name in CORE_TEST_LIST,
                  selected_tests,
              )
          )
  
      # Filter to only run functorch tests when --functorch option is specified
      if options.functorch:
          selected_tests = [
              tname
              for tname in selected_tests
              if tname in FUNCTORCH_TESTS
          ]
  
      if options.cpp:
          selected_tests = [
              tname for tname in selected_tests if tname in CPP_TESTS
          ]
      else:
          # Exclude all C++ tests otherwise as they are still handled differently
          # than Python test at the moment
          options.exclude.extend(CPP_TESTS)
  
      if options.mps:
          selected_tests = ["test_mps", "test_metal", "test_modules"]
      else:
          # Exclude all mps tests otherwise
          options.exclude.extend(["test_mps", "test_metal"])
  
      # Filter to only run onnx tests when --onnx option is specified
      onnx_tests = [
          tname for tname in selected_tests if tname in ONNX_TESTS
      ]
      if options.onnx:
          selected_tests = onnx_tests
      else:
          # Exclude all onnx tests otherwise
          options.exclude.extend(onnx_tests)
  
      # process exclusion
      if options.exclude_jit_executor:
          options.exclude.extend(JIT_EXECUTOR_TESTS)
  
      if options.exclude_distributed_tests:
          options.exclude.extend(DISTRIBUTED_TESTS)
  
      # these tests failing in CUDA 11.6 temporary disabling. issue https://github.com/pytorch/pytorch/issues/75375
      if torch.version.cuda is not None:
          options.exclude.extend(["distributions/test_constraints"])
  
      selected_tests = exclude_tests(options.exclude, selected_tests)
  
      if sys.platform == "win32" and not options.ignore_win_blocklist:
          target_arch = os.environ.get("VSCMD_ARG_TGT_ARCH")
          if target_arch != "x64":
              WINDOWS_BLOCKLIST.append("cpp_extensions_aot_no_ninja")
              WINDOWS_BLOCKLIST.append("cpp_extensions_aot_ninja")
              WINDOWS_BLOCKLIST.append("cpp_extensions_jit")
              WINDOWS_BLOCKLIST.append("jit")
              WINDOWS_BLOCKLIST.append("jit_fuser")
  
          selected_tests = exclude_tests(
              WINDOWS_BLOCKLIST, selected_tests, "on Windows"
          )
  
      elif TEST_WITH_ROCM:
          selected_tests = exclude_tests(
              ROCM_BLOCKLIST, selected_tests, "on ROCm"
          )
  
      # skip all distributed tests if distributed package is not available.
      if not dist.is_available():
          selected_tests = exclude_tests(
              DISTRIBUTED_TESTS,
              selected_tests,
              "PyTorch is built without distributed support.",
          )
  
      # skip tests that require LAPACK when it's not available
      if not torch._C.has_lapack:
          selected_tests = exclude_tests(
              TESTS_REQUIRING_LAPACK,
              selected_tests,
              "PyTorch is built without LAPACK support.",
          )
  
      if TEST_WITH_SLOW_GRADCHECK:
          selected_tests = exclude_tests(
              TESTS_NOT_USING_GRADCHECK,
              selected_tests,
              "Running in slow gradcheck mode, skipping tests "
              "that don't use gradcheck.",
              exact_match=True,
          )
  
      selected_tests = [parse_test_module(x) for x in selected_tests]
      return selected_tests
  
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 22 for calling a global function with example usage: get_selected_tests(options) and returns: selected_tests