code: def test(args, model, device, test_loader):
      model.eval()
      test_loss = 0
      correct = 0
      with torch.no_grad():
          for data, target in test_loader:
              data, target = data.to(device), target.to(device)
              output = model(data)
              # sum up batch loss
              test_loss += F.nll_loss(
                  output, target, reduction="sum"
              ).item()
              # get the index of the max log-probability
              pred = output.argmax(dim=1, keepdim=True)
              correct += pred.eq(target.view_as(pred)).sum().item()
  
      test_loss /= len(test_loader.dataset)
  
      accuracy = 100.0 * correct / len(test_loader.dataset)
  
      logger.info(
          "\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\n".format(
              test_loss, correct, len(test_loader.dataset), accuracy
          )
      )
  
      return accuracy
  
imports: import os
  import argparse
  import logging
  from collections import OrderedDict
  import nni
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torchvision import datasets, transforms
  from nni.nas.pytorch.mutables import LayerChoice, InputChoice
  from nni.algorithms.nas.pytorch.classic_nas import get_and_apply_next_architecture
label_desc: Use image node_id 2 for calling a global function with example usage: test(args, model, device, test_loader) and returns: accuracy