docstr: Validates the correctness of the :class:`Explanation` masks.
docstr_tok: ["Validates","the","correctness","of","the",":","class",":","`","Explanation","`","masks","."]
code: def validate_masks(self, raise_on_error: bool = True) -> bool:
      r"""Validates the correctness of the :class:`Explanation` masks."""
      status = True
  
      for store in self.node_stores:
          if "node_mask" not in store:
              continue
  
          if store.node_mask.dim() != 2:
              status = False
              warn_or_raise(
                  f"Expected a 'node_mask' with two dimensions (got "
                  f"{store.node_mask.dim()} dimensions)",
                  raise_on_error,
              )
  
          if store.node_mask.size(0) not in {1, store.num_nodes}:
              status = False
              warn_or_raise(
                  f"Expected a 'node_mask' with {store.num_nodes} nodes "
                  f"(got {store.node_mask.size(0)} nodes)",
                  raise_on_error,
              )
  
          if "x" in store:
              num_features = store.x.size(-1)
          else:
              num_features = store.node_mask.size(-1)
  
          if store.node_mask.size(1) not in {1, num_features}:
              status = False
              warn_or_raise(
                  f"Expected a 'node_mask' with {num_features} features ("
                  f"got {store.node_mask.size(1)} features)",
                  raise_on_error,
              )
  
      for store in self.edge_stores:
          if "edge_mask" not in store:
              continue
  
          if store.edge_mask.dim() != 1:
              status = False
              warn_or_raise(
                  f"Expected an 'edge_mask' with one dimension (got "
                  f"{store.edge_mask.dim()} dimensions)",
                  raise_on_error,
              )
  
          if store.edge_mask.size(0) != store.num_edges:
              status = False
              warn_or_raise(
                  f"Expected an 'edge_mask' with {store.num_edges} edges "
                  f"(got {store.edge_mask.size(0)} edges)",
                  raise_on_error,
              )
  
      return status
  
imports: import copy
  from typing import Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch_geometric.data.data import Data, warn_or_raise
  from torch_geometric.data.hetero_data import HeteroData
  from torch_geometric.explain.config import ThresholdConfig, ThresholdType
  from torch_geometric.typing import EdgeType, NodeType
  from torch_geometric.visualization import visualize_graph
label_desc: Use image node_id 2 for calling the ExplanationMixin obj's underlying member method code with example usage: obj.validate_masks(raise_on_error) and returns: status