code: def test_acc(model, criterion, log_freq, loader):
      logger.info("Start testing...")
      model.eval()
      meters = AverageMeterGroup()
      start_time = time.time()
      with torch.no_grad():
          for step, (inputs, targets) in enumerate(loader):
              inputs, targets = inputs.to("cuda"), targets.to("cuda")
              logits = model(inputs)
              loss = criterion(logits, targets)
              metrics = accuracy(logits, targets)
              metrics["loss"] = loss.item()
              meters.update(metrics)
              if step % log_freq == 0 or step + 1 == len(loader):
                  logger.info(
                      "Valid Step [%d/%d] time %.3fs acc1 %.4f acc5 %.4f loss %.4f",
                      step + 1,
                      len(loader),
                      time.time() - start_time,
                      meters.acc1.avg,
                      meters.acc5.avg,
                      meters.loss.avg,
                  )
      return meters.acc1.avg
  
imports: import time
  import json
  import random
  import logging
  import argparse
  import numpy
  import torch
  import torchvision.transforms
  import torchvision.datasets
  import nni
  from nn_meter import load_latency_predictor
  import nni.retiarii.nn.pytorch
  import nni.retiarii.strategy
  from nni.retiarii.evaluator.functional import FunctionalEvaluator
  from nni.retiarii.utils import original_state_dict_hooks
  from nni.retiarii.oneshot.pytorch.utils import AverageMeterGroup
  from nni.retiarii.experiment.pytorch import RetiariiExeConfig, RetiariiExperiment
  from network import ShuffleNetV2OneShot, load_and_parse_state_dict
  from utils import CrossEntropyLabelSmooth, accuracy, ToBGRTensor, get_archchoice_by_model
label_desc: Use image node_id 2 for calling a global function with example usage: test_acc(model, criterion, log_freq, loader) and returns: meters