class_docstr: Captum Interpretation for Resnet
class_docstr_tok: ["Captum","Interpretation","for","Resnet"]
code: def _get_attributions(
      self,
      enc_data,
      metric,
      n_steps,
      nt_type,
      baseline_type,
      strides,
      sliding_window_shapes,
  ):
      # Get Baseline
      baseline = self.get_baseline_img(enc_data[0], baseline_type)
      supported_metrics = {}
      if metric == "IG":
          self._int_grads = (
              self._int_grads
              if hasattr(self, "_int_grads")
              else IntegratedGradients(self.model)
          )
          return self._int_grads.attribute(
              enc_data[0], baseline, target=enc_data[1], n_steps=200
          )
      elif metric == "NT":
          self._int_grads = (
              self._int_grads
              if hasattr(self, "_int_grads")
              else IntegratedGradients(self.model)
          )
          self._noise_tunnel = (
              self._noise_tunnel
              if hasattr(self, "_noise_tunnel")
              else NoiseTunnel(self._int_grads)
          )
          return self._noise_tunnel.attribute(
              enc_data[0].to(self.dls.device),
              n_samples=1,
              nt_type=nt_type,
              target=enc_data[1],
          )
      elif metric == "Occl":
          self._occlusion = (
              self._occlusion
              if hasattr(self, "_occlusion")
              else Occlusion(self.model)
          )
          return self._occlusion.attribute(
              enc_data[0].to(self.dls.device),
              strides=strides,
              target=enc_data[1],
              sliding_window_shapes=sliding_window_shapes,
              baselines=baseline,
          )
  
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 6 for calling the CaptumInterpretation obj's underlying member method code with example usage: obj._get_attributions(enc_data, metric, n_steps, nt_type, baseline_type, strides, sliding_window_shapes) and returns: self, self, self