code: def evaluate(model, loader, criterion, evaluator):
      model.eval()
      total_loss = []
      y_true = []
      y_pred = []
      is_valid = []
  
      for idx, batch_data in enumerate(loader):
          g, mh_graphs, labels, unmask = batch_data
          g = g.tensor()
          multihop_graphs = []
          for item in mh_graphs:
              multihop_graphs.append(item.tensor())
          g.multi_hop_graphs = multihop_graphs
          labels = paddle.to_tensor(labels)
          unmask = paddle.to_tensor(unmask)
  
          pred = model(g)
          eval_loss = criterion(
              paddle.masked_select(pred, unmask),
              paddle.masked_select(labels, unmask),
          )
          total_loss.append(eval_loss.numpy())
  
          y_pred.append(pred.numpy())
          y_true.append(labels.numpy())
          is_valid.append(unmask.numpy())
  
      y_pred = np.concatenate(y_pred)
      y_true = np.concatenate(y_true)
      is_valid = np.concatenate(is_valid)
      is_valid = is_valid.astype("bool")
      y_true = y_true.astype("float32")
      y_true[~is_valid] = np.nan
      input_dict = {"y_true": y_true, "y_pred": y_pred}
      result = evaluator.eval(input_dict)
  
      total_loss = np.mean(total_loss)
      model.train()
  
      return {
          "loss": total_loss,
          config.metrics: result[config.metrics],
      }
  
imports: import ssl
  import os
  import sys
  import time
  import argparse
  import numpy
  from datetime import datetime
  from ogb.graphproppred import GraphPropPredDataset, Evaluator
  from tensorboardX import SummaryWriter
  import paddle
  import paddle.nn
  from paddle.optimizer import Adam
  import paddle.distributed
  import pgl
  from pgl.utils.logger import log
  from pgl.utils.data import Dataloader
  from model import ClassifierNetwork
  from dataset import Subset, MolDataset, make_multihop_edges, CollateFn
  from utils.config import prepare_config, make_dir
  from utils.logger import prepare_logger, log_to_file
label_desc: Use image node_id 2 for calling a global function with example usage: evaluate(model, loader, criterion, evaluator) and returns: dict