code: def check_explanation(
      explanation: Explanation,
      node_mask_type: Optional[MaskType],
      edge_mask_type: Optional[MaskType],
  ):
      if node_mask_type == MaskType.attributes:
          assert explanation.node_mask.size() == explanation.x.size()
      elif node_mask_type is None:
          assert "node_mask" not in explanation
  
      if edge_mask_type == MaskType.object:
          assert explanation.edge_mask.size() == (
              explanation.num_edges,
          )
      elif edge_mask_type is None:
          assert "edge_mask" not in explanation
  
file_path: pytorch_geometric/test/explain/algorithm/test_captum_explainer.py
imports: from typing import Optional
  import pytest
  import torch
  from torch_geometric.explain import Explainer, Explanation
  from torch_geometric.explain.algorithm import CaptumExplainer
  from torch_geometric.explain.config import MaskType, ModelConfig, ModelMode, ModelReturnType, ModelTaskLevel
  from torch_geometric.nn import GCNConv, global_add_pool
  from torch_geometric.testing import withPackage
label_desc: Use image node_id 1 for calling a global function with example usage: check_explanation(explanation, node_mask_type, edge_mask_type) without return types