code: def test(args, test_loader, gpmodule):
      correct = 0
      for data, target in test_loader:
          if args.cuda:
              data, target = data.cuda(), target.cuda()
          if args.binary:
              target = (
                  target % 2
              ).float()  # convert numbers 0->9 to 0 or 1
  
          # get prediction of GP model on new data
          f_loc, f_var = gpmodule(data)
          # use its likelihood to give prediction class
          pred = gpmodule.likelihood(f_loc, f_var)
          # compare prediction and target to count accuracy
          correct += pred.eq(target).long().cpu().sum().item()
  
      print(
          "\nTest set: Accuracy: {}/{} ({:.2f}%)\n".format(
              correct,
              len(test_loader.dataset),
              100.0 * correct / len(test_loader.dataset),
          )
      )
  
file_path: pyro/examples/contrib/gp/sv-dkl.py
imports: import argparse
  import time
  import torch
  import torch.nn
  import torch.nn.functional
  from torchvision import transforms
  import pyro
  import pyro.contrib.gp
  import pyro.infer
  from pyro.contrib.examples.util import get_data_directory, get_data_loader
label_desc: Use image node_id 2 for calling a global function with example usage: test(args, test_loader, gpmodule) without return types