code: def test_explainer_dependencies(opt_dep):
      """Tests that the explainer module correctly protects against uninstalled optional dependencies.
  
      Note: counterfactual rl base and tabular requre one of torch or tensorflow. They will fail if a user tries to
      initialize them without one of tf or torch, but they should still import correctly for the default install option.
      The backend optional dependency behaviour is tested for in the backend tests.
      """
  
      explainer_dependency_map = defaultdict(lambda: ["default"])
      for dependency, relations in [
          ("AnchorImage", ["default"]),
          ("AnchorTabular", ["default"]),
          ("AnchorText", ["default"]),
          ("CEM", ["tensorflow"]),
          ("CounterFactual", ["tensorflow"]),
          ("CounterFactualProto", ["tensorflow"]),
          ("Counterfactual", ["tensorflow"]),
          ("CounterfactualProto", ["tensorflow"]),
          ("CounterfactualRL", ["default"]),  # See above note
          ("CounterfactualRLTabular", ["default"]),  # See above note
          ("DistributedAnchorTabular", ["ray"]),
          ("IntegratedGradients", ["tensorflow"]),
          ("KernelShap", ["shap"]),
          ("TreeShap", ["shap"]),
          ("plot_ale", ["default"]),
      ]:
          explainer_dependency_map[dependency] = relations
      from alibi import explainers
  
      check_correct_dependencies(
          explainers, explainer_dependency_map, opt_dep
      )
  
file_path: alibi/alibi/tests/test_dep_management.py
imports: from types import ModuleType
  from collections import defaultdict
label_desc: Use image node_id 2 for calling a global function with example usage: test_explainer_dependencies(opt_dep) without return types