code: def check_explanation():
      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()
              )
              assert explanation.node_mask.min() >= 0
              assert explanation.node_mask.max() <= 1
          elif node_mask_type == MaskType.object:
              assert explanation.node_mask.size() == (
                  explanation.num_nodes,
                  1,
              )
              assert explanation.node_mask.min() >= 0
              assert explanation.node_mask.max() <= 1
          elif node_mask_type == MaskType.common_attributes:
              assert explanation.node_mask.size() == (
                  1,
                  explanation.x.size(-1),
              )
              assert explanation.node_mask.min() >= 0
              assert explanation.node_mask.max() <= 1
          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,
              )
              assert explanation.edge_mask.min() >= 0
              assert explanation.edge_mask.max() <= 1
          elif edge_mask_type is None:
              assert "edge_mask" not in explanation
  
      return _check_explanation
  
file_path: pytorch_geometric/test/explain/conftest.py
imports: from typing import Optional
  import pytest
  import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.explain import Explanation
  from torch_geometric.explain.config import MaskType
  from torch_geometric.nn import SAGEConv, to_hetero
  from torch_geometric.testing import get_random_edge_index
label_desc: Use image node_id 4 for calling a global function with example usage: check_explanation() and returns: _check_explanation