code: def eval(model, device, loader, evaluator):
      model.eval()
      y_true = []
      y_pred = []
  
      for step, (bg, labels) in enumerate(
          tqdm(loader, desc="Iteration")
      ):
          bg = bg.to(device)
          x = bg.ndata.pop("feat")
          edge_attr = bg.edata.pop("feat")
          labels = labels.to(device)
  
          with torch.no_grad():
              pred = model(bg, x, edge_attr).view(
                  -1,
              )
  
          y_true.append(labels.view(pred.shape).detach().cpu())
          y_pred.append(pred.detach().cpu())
  
      y_true = torch.cat(y_true, dim=0)
      y_pred = torch.cat(y_pred, dim=0)
  
      input_dict = {"y_true": y_true, "y_pred": y_pred}
  
      return evaluator.eval(input_dict)["mae"]
  
file_path: dgl/examples/pytorch/ogb_lsc/PCQM4M/main.py
imports: import argparse
  import os
  import random
  import dgl
  import numpy
  import torch
  import torch.optim
  from gnn import GNN
  from ogb.lsc import DglPCQM4MDataset, PCQM4MEvaluator
  from torch.optim.lr_scheduler import StepLR
  from torch.utils.data import DataLoader
  from torch.utils.tensorboard import SummaryWriter
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling a global function with example usage: eval(model, device, loader, evaluator) and returns: evaluator