class_docstr: Tests just-in-time cpp extensions.
  Don't confuse this with the PyTorch JIT (aka TorchScript).
code: def _run_jit_cuda_archflags(self, flags, expected):
      # Compile an extension with given `flags`
      def _check_cuobjdump_output(expected_values, is_ptx=False):
          elf_or_ptx = "--list-ptx" if is_ptx else "--list-elf"
          lib_ext = ".pyd" if IS_WINDOWS else ".so"
          # Note, .extension name may include _v1, _v2, so first find exact name
          ext_filename = glob.glob(
              os.path.join(temp_dir, "cudaext_archflag*" + lib_ext)
          )[0]
          command = ["cuobjdump", elf_or_ptx, ext_filename]
          p = subprocess.Popen(
              command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
          )
          output, err = p.communicate()
          output = output.decode("ascii")
          err = err.decode("ascii")
  
          if not p.returncode == 0 or not err == "":
              raise AssertionError(
                  f"Flags: {flags}\nReturncode: {p.returncode}\nStderr: {err}\n"
                  f"Output: {output} "
              )
  
          actual_arches = sorted(re.findall(r"sm_\d\d", output))
          expected_arches = sorted(
              ["sm_" + xx for xx in expected_values]
          )
          self.assertEqual(
              actual_arches,
              expected_arches,
              msg=f"Flags: {flags},  Actual: {actual_arches},  Expected: {expected_arches}\n"
              f"Stderr: {err}\nOutput: {output}",
          )
  
      temp_dir = tempfile.mkdtemp()
      old_envvar = os.environ.get("TORCH_CUDA_ARCH_LIST", None)
      try:
          os.environ["TORCH_CUDA_ARCH_LIST"] = flags
  
          params = {
              "name": "cudaext_archflags",
              "sources": [
                  "cpp_extensions/cuda_extension.cpp",
                  "cpp_extensions/cuda_extension.cu",
              ],
              "extra_cuda_cflags": ["-O2"],
              "verbose": True,
              "build_directory": temp_dir,
          }
  
          if IS_WINDOWS:
              p = mp.Process(
                  target=torch.utils.cpp_extension.load, kwargs=params
              )
  
              # Compile and load the test CUDA arch in a different Python process to avoid
              # polluting the current one and causes test_jit_cuda_extension to fail on
              # Windows. There is no clear way to unload a module after it has been imported
              # and torch.utils.cpp_extension.load builds and loads the module in one go.
              # See https://github.com/pytorch/pytorch/issues/61655 for more details
              p.start()
              p.join()
          else:
              torch.utils.cpp_extension.load(**params)
  
          # Expected output for --list-elf:
          #   ELF file    1: cudaext_archflags.1.sm_61.cubin
          #   ELF file    2: cudaext_archflags.2.sm_52.cubin
          _check_cuobjdump_output(expected[0])
          if expected[1] is not None:
              # Expected output for --list-ptx:
              #   PTX file    1: cudaext_archflags.1.sm_61.ptx
              _check_cuobjdump_output(expected[1], is_ptx=True)
      finally:
          if IS_WINDOWS:
              # rmtree returns permission error: [WinError 5] Access is denied
              # on Windows, this is a word-around
              subprocess.run(
                  ["rm", "-rf", temp_dir], stdout=subprocess.PIPE
              )
          else:
              shutil.rmtree(temp_dir)
  
          if old_envvar is None:
              os.environ.pop("TORCH_CUDA_ARCH_LIST")
          else:
              os.environ["TORCH_CUDA_ARCH_LIST"] = old_envvar
  
imports: import os
  import shutil
  import sys
  import unittest
  import warnings
  import re
  import tempfile
  import subprocess
  import glob
  import torch.testing._internal.common_utils
  from torch.testing._internal.common_cuda import TEST_CUDNN, TEST_CUDA
  import torch
  import torch.backends.cudnn
  import torch.utils.cpp_extension
  from torch.utils.cpp_extension import CUDA_HOME, ROCM_HOME
  from torch.testing._internal.common_utils import gradcheck
  import torch.multiprocessing
  from torch.utils.cpp_extension import _TORCH_PATH, remove_extension_h_precompiler_headers, get_cxx_compiler, check_compiler_is_gcc
label_desc: Use image node_id 8 for calling the TestCppExtensionJIT obj's underlying member method code with example usage: obj._run_jit_cuda_archflags(flags, expected) without return types