code: def insights(x: CaptumInterpretation, inp_data, debug=True):
      _baseline_func = lambda o: o * 0
      _get_vocab = (
          lambda vocab: list(map(str, vocab))
          if isinstance(vocab[0], bool)
          else vocab
      )
      dl = x.dls.test_dl(L(inp_data), with_labels=True, bs=4)
      normalize_func = next(
          (func for func in dl.after_batch if type(func) == Normalize),
          noop,
      )
  
      # captum v0.3 expects tensors without the batch dimension.
      if nested_attr(normalize_func, "mean.ndim", 4) == 4:
          normalize_func.mean.squeeze_(0)
      if nested_attr(normalize_func, "std.ndim", 4) == 4:
          normalize_func.std.squeeze_(0)
  
      visualizer = AttributionVisualizer(
          models=[x.model],
          score_func=lambda o: torch.nn.functional.softmax(o, 1),
          classes=_get_vocab(dl.vocab),
          features=[
              ImageFeature(
                  "Image",
                  baseline_transforms=[_baseline_func],
                  input_transforms=[normalize_func],
              )
          ],
          dataset=x._formatted_data_iter(dl, normalize_func),
      )
      visualizer.render(debug=debug)
  
file_path: fastai/fastai/callback/captum.py
imports: from __future__ import annotations
  import tempfile
  from ..basics import *
  from ipykernel import jsonutil
  from captum.attr import IntegratedGradients, NoiseTunnel, GradientShap, Occlusion
  from captum.attr import visualization
  from matplotlib.colors import LinearSegmentedColormap
  from captum.insights import AttributionVisualizer, Batch
  from captum.insights.attr_vis.features import ImageFeature
label_desc: Use image node_id 2 for calling a global function with example usage: insights(x, inp_data, debug) without return types