code: def loss_op(pred, y, index, loss_func):
      r"""
      A helper function for the heterogeneous loss operations.
      This function will sum the loss of all node types.
  
      Args:
          pred (Dict[str, Tensor]): A dictionary of prediction results.
          y (Dict[str, Tensor]): A dictionary of labels. The keys should match with
              the keys in the `pred`.
          index (Dict[str, Tensor]): A dictionary of indicies that the loss
              will be computed on. Each value should be :class:`torch.LongTensor`.
              Notice that `y` will not be indexed by the `index`. Here we assume
              `y` has been splitted into proper sets.
          loss_func (callable): The defined loss function.
      """
      loss = 0
      for node_type in pred:
          idx = index[node_type]
          loss += loss_func(pred[node_type][idx], y[node_type])
      return loss
  
imports: import collections.abc
  import torch
  import torch_geometric.nn
  import torch_geometric.utils
  import torch.nn
  from torch import Tensor
  from torch_geometric.nn.inits import reset
  from torch_sparse import matmul
  from typing import List, Dict
label_desc: Use image node_id 2 for calling a global function with example usage: loss_op(pred, y, index, loss_func) and returns: loss