code: def loaded_vispy_modules(
      import_module, depth=None, all_modules=False
  ):
      """Import the given module in subprocess and return loaded modules
  
      Import a certain module in a clean subprocess and return the
      vispy modules that are subsequently loaded. The given depth
      indicates the module level (i.e. depth=1 will only yield 'vispy.app'
      but not 'vispy.app.backends').
      """
      vispy_dir = os.path.dirname(os.path.dirname(vispy.__file__))
  
      # Get the loaded modules in a clean interpreter
      code = (
          "import sys, %s; print(', '.join(sys.modules))"
          % import_module
      )
      res = run_subprocess([sys.executable, "-c", code], cwd=vispy_dir)[
          0
      ]
      loaded_modules = [name.strip() for name in res.split(",")]
  
      if all_modules:
          return loaded_modules
  
      # Get only vispy modules at the given depth
      vispy_modules = set()
      for m in loaded_modules:
          # pkg_resources from vispy/__init__.py shows up as vispy.pkg_resources in python 2.7
          if (
              m.startswith("vispy")
              and "__future__" not in m
              and "pkg_resources" not in m
          ):
              if depth:
                  parts = m.split(".")
                  m = ".".join(parts[:depth])
              vispy_modules.add(m)
  
      return vispy_modules
  
file_path: vispy/vispy/util/tests/test_import.py
imports: import sys
  import os
  from vispy.testing import assert_in, assert_not_in, requires_pyopengl, run_tests_if_main, assert_equal
  from vispy.util import run_subprocess
  import vispy
label_desc: Use image node_id 1 for calling a global function with example usage: loaded_vispy_modules(import_module, depth, all_modules) and returns: vispy_modules, loaded_modules