code: def test(dataloader, model, loss_fn):
      size = len(dataloader.dataset)
      num_batches = len(dataloader)
      model.eval()
      test_loss, correct = 0, 0
      with torch.no_grad():
          for X, y in dataloader:
              X, y = X.to(device), y.to(device)
              pred = model(X)
              test_loss += loss_fn(pred, y).item()
              correct += (
                  (pred.argmax(1) == y).type(torch.float).sum().item()
              )
      test_loss /= num_batches
      correct /= size
      return correct
  
file_path: nni/docs/source/tutorials/hpo_quickstart_pytorch/model.py
imports: import nni
  import torch
  from torch import nn
  from torch.utils.data import DataLoader
  from torchvision import datasets
  from torchvision.transforms import ToTensor
label_desc: Use image node_id 2 for calling a global function with example usage: test(dataloader, model, loss_fn) and returns: correct