code: def get_plugin(cuda_file):
      cuda_file_base = os.path.basename(cuda_file)
      cuda_file_name, cuda_file_ext = os.path.splitext(cuda_file_base)
  
      # Already in cache?
      if cuda_file in _plugin_cache:
          return _plugin_cache[cuda_file]
  
      # Setup plugin.
      if verbose:
          print(
              'Setting up TensorFlow plugin "%s": ' % cuda_file_base,
              end="",
              flush=True,
          )
      try:
          # Hash CUDA source.
          md5 = hashlib.md5()
          with open(cuda_file, "rb") as f:
              md5.update(f.read())
          md5.update(b"\n")
  
          # Hash headers included by the CUDA code by running it through the preprocessor.
          if not do_not_hash_included_headers:
              if verbose:
                  print("Preprocessing... ", end="", flush=True)
              with tempfile.TemporaryDirectory() as tmp_dir:
                  tmp_file = os.path.join(
                      tmp_dir, cuda_file_name + "_tmp" + cuda_file_ext
                  )
                  _run_cmd(
                      _prepare_nvcc_cli(
                          '"%s" --preprocess -o "%s" --keep --keep-dir "%s"'
                          % (cuda_file, tmp_file, tmp_dir)
                      )
                  )
                  with open(tmp_file, "rb") as f:
                      bad_file_str = (
                          '"' + cuda_file.replace("\\", "/") + '"'
                      ).encode(
                          "utf-8"
                      )  # __FILE__ in error check macros
                      good_file_str = (
                          '"' + cuda_file_base + '"'
                      ).encode("utf-8")
                      for ln in f:
                          if not ln.startswith(
                              b"# "
                          ) and not ln.startswith(
                              b"#line "
                          ):  # ignore line number pragmas
                              ln = ln.replace(
                                  bad_file_str, good_file_str
                              )
                              md5.update(ln)
                      md5.update(b"\n")
  
          # Select compiler options.
          compile_opts = ""
          if os.name == "nt":
              compile_opts += '"%s"' % os.path.join(
                  tf.sysconfig.get_lib(),
                  "python",
                  "_pywrap_tensorflow_internal.lib",
              )
          elif os.name == "posix":
              compile_opts += '"%s"' % os.path.join(
                  tf.sysconfig.get_lib(),
                  "python",
                  "_pywrap_tensorflow_internal.so",
              )
              compile_opts += " --compiler-options '-fPIC -D_GLIBCXX_USE_CXX11_ABI=0'"
          else:
              assert False  # not Windows or Linux, w00t?
          compile_opts += (
              " --gpu-architecture=%s" % _get_cuda_gpu_arch_string()
          )
          compile_opts += " --use_fast_math"
          nvcc_cmd = _prepare_nvcc_cli(compile_opts)
  
          # Hash build configuration.
          md5.update(("nvcc_cmd: " + nvcc_cmd).encode("utf-8") + b"\n")
          md5.update(
              ("tf.VERSION: " + tf.VERSION).encode("utf-8") + b"\n"
          )
          md5.update(
              (
                  "cuda_cache_version_tag: " + cuda_cache_version_tag
              ).encode("utf-8")
              + b"\n"
          )
  
          # Compile if not already compiled.
          bin_file_ext = ".dll" if os.name == "nt" else ".so"
          bin_file = os.path.join(
              cuda_cache_path,
              cuda_file_name + "_" + md5.hexdigest() + bin_file_ext,
          )
          if not os.path.isfile(bin_file):
              if verbose:
                  print("Compiling... ", end="", flush=True)
              with tempfile.TemporaryDirectory() as tmp_dir:
                  tmp_file = os.path.join(
                      tmp_dir, cuda_file_name + "_tmp" + bin_file_ext
                  )
                  _run_cmd(
                      nvcc_cmd
                      + ' "%s" --shared -o "%s" --keep --keep-dir "%s"'
                      % (cuda_file, tmp_file, tmp_dir)
                  )
                  os.makedirs(cuda_cache_path, exist_ok=True)
                  intermediate_file = os.path.join(
                      cuda_cache_path,
                      cuda_file_name
                      + "_"
                      + uuid.uuid4().hex
                      + "_tmp"
                      + bin_file_ext,
                  )
                  shutil.copyfile(tmp_file, intermediate_file)
                  os.rename(intermediate_file, bin_file)  # atomic
  
          # Load.
          if verbose:
              print("Loading... ", end="", flush=True)
          plugin = tf.load_op_library(bin_file)
  
          # Add to cache.
          _plugin_cache[cuda_file] = plugin
          if verbose:
              print("Done.", flush=True)
          return plugin
  
      except:
          if verbose:
              print("Failed!", flush=True)
          raise
  
file_path: insightface/reconstruction/ostec/external/stylegan2/dnnlib/tflib/custom_ops.py
imports: import os
  import re
  import uuid
  import hashlib
  import tempfile
  import shutil
  import tensorflow
  from tensorflow.python.client import device_lib
label_desc: Use image node_id 6 for calling a global function with example usage: get_plugin(cuda_file) and returns: _plugin_cache, plugin