code: def test_captum_attribution_methods(mask_type, method):
      from captum import attr  # noqa
  
      captum_model = to_captum_model(GCN, mask_type, 0)
      explainer = getattr(attr, method)(captum_model)
      data = Data(x, edge_index)
      input, additional_forward_args = to_captum_input(
          data.x, data.edge_index, mask_type
      )
      if mask_type == "node":
          sliding_window_shapes = (3, 3)
      elif mask_type == "edge":
          sliding_window_shapes = (5,)
      elif mask_type == "node_and_edge":
          sliding_window_shapes = ((3, 3), (5,))
  
      if method == "IntegratedGradients":
          attributions, delta = explainer.attribute(
              input,
              target=0,
              internal_batch_size=1,
              additional_forward_args=additional_forward_args,
              return_convergence_delta=True,
          )
      elif method == "GradientShap":
          attributions, delta = explainer.attribute(
              input,
              target=0,
              return_convergence_delta=True,
              baselines=input,
              n_samples=1,
              additional_forward_args=additional_forward_args,
          )
      elif method == "DeepLiftShap" or method == "DeepLift":
          attributions, delta = explainer.attribute(
              input,
              target=0,
              return_convergence_delta=True,
              baselines=input,
              additional_forward_args=additional_forward_args,
          )
      elif method == "Occlusion":
          attributions = explainer.attribute(
              input,
              target=0,
              sliding_window_shapes=sliding_window_shapes,
              additional_forward_args=additional_forward_args,
          )
      else:
          attributions = explainer.attribute(
              input,
              target=0,
              additional_forward_args=additional_forward_args,
          )
      if mask_type == "node":
          assert attributions[0].shape == (1, 8, 3)
      elif mask_type == "edge":
          assert attributions[0].shape == (1, 14)
      else:
          assert attributions[0].shape == (1, 8, 3)
          assert attributions[1].shape == (1, 14)
  
file_path: pytorch_geometric/test/explain/algorithm/test_captum.py
imports: import pytest
  import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.explain.algorithm.captum import to_captum_input
  from torch_geometric.nn import GAT, GCN, SAGEConv
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.nn.models import to_captum_model
  from torch_geometric.testing import withPackage
label_desc: Use image node_id 2 for calling a global function with example usage: test_captum_attribution_methods(mask_type, method) without return types