code: def test_node_mask(data):
      node_mask = torch.tensor([[1.0], [0.0], [1.0], [0.0]])
  
      explanation = Explanation(
          node_mask=node_mask,
          x=data.x,
          edge_index=data.edge_index,
          edge_attr=data.edge_attr,
      )
      explanation.validate(raise_on_error=True)
  
      out = explanation.get_explanation_subgraph()
      assert out.node_mask.size() == (2, 1)
      assert (out.node_mask > 0.0).sum() == 2
      assert out.x.size() == (2, 3)
      assert out.edge_index.size(1) <= 6
      assert out.edge_index.size(1) == out.edge_attr.size(0)
  
      out = explanation.get_complement_subgraph()
      assert out.node_mask.size() == (2, 1)
      assert (out.node_mask == 0.0).sum() == 2
      assert out.x.size() == (2, 3)
      assert out.edge_index.size(1) <= 6
      assert out.edge_index.size(1) == out.edge_attr.size(0)
  
file_path: pytorch_geometric/test/explain/test_explanation.py
imports: import os.path
  from typing import Optional, Union
  import pytest
  import torch
  from torch_geometric.data import Data
  from torch_geometric.explain import Explanation
  from torch_geometric.explain.config import MaskType
  from torch_geometric.testing import withPackage
label_desc: Use image node_id 4 for calling a global function with example usage: test_node_mask(data) without return types