code: def evaluate(
      dataset,
      g,
      feats,
      model,
      node_embed,
      labels,
      device,
      idx,
      save_test_submission=False,
  ):
      # Switches the model to evaluation mode.
      model.eval()
      category = "paper"
      if dataset == "ogbn-mag":
          evaluator = Evaluator(name="ogbn-mag")
      else:
          evaluator = MAG240MEvaluator()
  
      sampler = dgl.dataloading.MultiLayerNeighborSampler([25, 10])
      dataloader = dgl.dataloading.DataLoader(
          g,
          idx,
          sampler,
          batch_size=4096,
          shuffle=False,
          num_workers=0,
          device=device,
      )
  
      # To store the predictions.
      y_hats = list()
      y_true = list()
  
      for input_nodes, seeds, blocks in tqdm(
          dataloader, desc="Inference"
      ):
          blocks = [blk.to(device) for blk in blocks]
          # We only predict the nodes with type "category".
          node_features = extract_node_features(
              dataset, g, input_nodes, node_embed, feats, device
          )
  
          # Generate predictions.
          logits = model(node_features, blocks)[category]
          # Apply softmax to the logits and get the prediction by selecting the
          # argmax.
          y_hat = logits.log_softmax(dim=-1).argmax(
              dim=1, keepdims=True
          )
          y_hats.append(y_hat.cpu())
          y_true.append(labels[seeds["paper"].cpu()])
  
      y_pred = torch.cat(y_hats, dim=0)
      y_true = torch.cat(y_true, dim=0)
      y_true = torch.unsqueeze(y_true, 1)
  
      if dataset == "ogb-lsc-mag240m":
          y_pred = y_pred.view(-1)
          y_true = y_true.view(-1)
  
      if save_test_submission:
          evaluator.save_test_submission(
              input_dict={"y_pred": y_pred},
              dir_path=".",
              mode="test-dev",
          )
      return evaluator.eval({"y_true": y_true, "y_pred": y_pred})["acc"]
  
imports: import argparse
  import itertools
  import sys
  import time
  import dgl
  import dgl.nn
  import numpy
  import psutil
  import torch
  import torch.nn
  import torch.nn.functional
  from dgl import AddReverse, Compose, ToSimple
  from dgl.nn import HeteroEmbedding
  from ogb.lsc import MAG240MDataset, MAG240MEvaluator
  from ogb.nodeproppred import DglNodePropPredDataset, Evaluator
  from tqdm import tqdm
label_desc: Use image node_id 6 for calling a global function with example usage: evaluate(dataset, g, feats, model, node_embed, labels, device, idx, save_test_submission) and returns: evaluator