code: def check_correct_dependencies(
      module: ModuleType, dependencies: defaultdict, opt_dep: str
  ):
      """Checks that imported modules that depend on optional dependencies throw correct errors on use.
  
      Parameters
      ----------
      module
          The module to check. Each of the public objects within this module will be checked.
      dependencies
          A dictionary mapping the name of the object to the list of optional dependencies that it depends on. If a name
          is not in the dictionary, the named object is assumed to be independent of optional dependencies. Therefor it
          should pass for the default alibi install.
      opt_dep
          The name of the optional dependency that is being tested.
      """
      lib_obj = [obj for obj in dir(module) if not obj.startswith("_")]
      for item_name in lib_obj:
          item = getattr(module, item_name)
          if not isinstance(item, ModuleType):
              pass_contexts = dependencies[item_name]
              try:
                  item.test  # noqa
              except AttributeError:
                  assert (
                      opt_dep in pass_contexts
                      or "default" in pass_contexts
                      or opt_dep == "all"
                  ), (
                      f"{item_name} was imported instead of an instance of MissingDependency. "
                      f"Are your sure {item} is dependent on {opt_dep}?"
                  )
              except ImportError:
                  assert (
                      opt_dep not in pass_contexts
                      and "default" not in pass_contexts
                      and opt_dep != "all"
                  ), (
                      f"{item_name} has been imported as an instance of MissingDependency. "
                      f"Are you sure the dependency buckets, {pass_contexts} are correct?"
                  )
  
file_path: alibi/alibi/tests/test_dep_management.py
imports: from types import ModuleType
  from collections import defaultdict
label_desc: Use image node_id 1 for calling a global function with example usage: check_correct_dependencies(module, dependencies, opt_dep) without return types