code: def test_validate_explanation(hetero_data):
      explanation = create_random_explanation(hetero_data)
      explanation.validate(raise_on_error=True)
  
      with pytest.raises(ValueError, match="with 8 nodes"):
          explanation = create_random_explanation(hetero_data)
          explanation["paper"].node_mask = torch.rand(5, 5)
          explanation.validate(raise_on_error=True)
  
      with pytest.raises(ValueError, match="with 5 features"):
          explanation = create_random_explanation(
              hetero_data, "attributes"
          )
          explanation["paper"].x = torch.randn(8, 5)
          explanation.validate(raise_on_error=True)
  
      with pytest.raises(ValueError, match="with 10 edges"):
          explanation = create_random_explanation(hetero_data)
          explanation["paper", "paper"].edge_mask = torch.randn(5)
          explanation.validate(raise_on_error=True)
  
file_path: pytorch_geometric/test/explain/test_hetero_explanation.py
imports: import os.path
  from typing import Optional, Union
  import pytest
  import torch
  from torch_geometric.data import HeteroData
  from torch_geometric.explain import HeteroExplanation
  from torch_geometric.explain.config import MaskType
  from torch_geometric.testing import withPackage
label_desc: Use image node_id 3 for calling a global function with example usage: test_validate_explanation(hetero_data) without return types