code: def generate_candidate_libs(lib_names, lib_dirs=None):
      """Generate a list of candidate filenames of what might be the dynamic
      library corresponding with the given list of names.
      Returns (lib_dirs, lib_paths)
      """
      lib_dirs = lib_dirs or []
  
      # Get system dirs to search
      sys_lib_dirs = [
          "/lib",
          "/usr/lib",
          "/usr/lib/x86_64-linux-gnu",
          "/usr/lib/aarch64-linux-gnu",
          "/usr/local/lib",
          "/opt/local/lib",
      ]
  
      # Get Python dirs to search (shared if for Pyzo)
      py_sub_dirs = ["bin", "lib", "DLLs", "Library/bin", "shared"]
      py_lib_dirs = [os.path.join(sys.prefix, d) for d in py_sub_dirs]
      if hasattr(sys, "base_prefix"):
          py_lib_dirs += [
              os.path.join(sys.base_prefix, d) for d in py_sub_dirs
          ]
  
      # Get user dirs to search (i.e. HOME)
      home_dir = os.path.expanduser("~")
      user_lib_dirs = [os.path.join(home_dir, d) for d in ["lib"]]
  
      # Select only the dirs for which a directory exists, and remove duplicates
      potential_lib_dirs = (
          lib_dirs + sys_lib_dirs + py_lib_dirs + user_lib_dirs
      )
      lib_dirs = []
      for ld in potential_lib_dirs:
          if os.path.isdir(ld) and ld not in lib_dirs:
              lib_dirs.append(ld)
  
      # Now attempt to find libraries of that name in the given directory
      # (case-insensitive)
      lib_paths = []
      for lib_dir in lib_dirs:
          # Get files, prefer short names, last version
          files = os.listdir(lib_dir)
          files = reversed(sorted(files))
          files = sorted(files, key=len)
          for lib_name in lib_names:
              # Test all filenames for name and ext
              for fname in files:
                  if fname.lower().startswith(lib_name) and looks_lib(
                      fname
                  ):
                      lib_paths.append(os.path.join(lib_dir, fname))
  
      # Return (only the items which are files)
      lib_paths = [lp for lp in lib_paths if os.path.isfile(lp)]
      return lib_dirs, lib_paths
  
imports: import os
  import sys
  import ctypes
label_desc: Use image node_id 2 for calling a global function with example usage: generate_candidate_libs(lib_names, lib_dirs) and returns: lib_dirs,  lib_paths