code: def filter_hetero_data(
      data: HeteroData,
      node_dict: Dict[NodeType, Tensor],
      row_dict: Dict[EdgeType, Tensor],
      col_dict: Dict[EdgeType, Tensor],
      edge_dict: Dict[EdgeType, OptTensor],
      perm_dict: Optional[Dict[EdgeType, OptTensor]] = None,
  ) -> HeteroData:
      # Filters a heterogeneous data object to only hold nodes in `node` and
      # edges in `edge` for each node and edge type, respectively:
      out = copy.copy(data)
  
      for node_type in out.node_types:
          # Handle the case of disconneted graph sampling:
          if node_type not in node_dict:
              node_dict[node_type] = torch.empty(0, dtype=torch.long)
  
          filter_node_store_(
              data[node_type], out[node_type], node_dict[node_type]
          )
  
      for edge_type in out.edge_types:
          # Handle the case of disconneted graph sampling:
          if edge_type not in row_dict:
              row_dict[edge_type] = torch.empty(0, dtype=torch.long)
          if edge_type not in col_dict:
              col_dict[edge_type] = torch.empty(0, dtype=torch.long)
          if edge_type not in edge_dict:
              edge_dict[edge_type] = torch.empty(0, dtype=torch.long)
  
          filter_edge_store_(
              data[edge_type],
              out[edge_type],
              row_dict[edge_type],
              col_dict[edge_type],
              edge_dict[edge_type],
              perm_dict.get(edge_type, None) if perm_dict else None,
          )
  
      return out
  
imports: import copy
  import logging
  import math
  from typing import Any, Dict, Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  import torch_geometric.typing
  from torch_geometric import EdgeIndex
  from torch_geometric.data import Data, FeatureStore, GraphStore, HeteroData, TensorAttr, remote_backend_utils
  from torch_geometric.data.storage import EdgeStorage, NodeStorage
  from torch_geometric.typing import EdgeType, FeatureTensorType, InputEdges, InputNodes, NodeType, OptTensor, SparseTensor, TensorFrame
label_desc: Use image node_id 5 for calling a global function with example usage: filter_hetero_data(data, node_dict, row_dict, col_dict, edge_dict, perm_dict) and returns: out