code: def validate(model, auxiliarynet, valid_loader, device, logger):
      """Do validation."""
      model.eval()
      auxiliarynet.eval()
  
      losses, nme = list(), list()
      with torch.no_grad():
          for i, (img, land_gt, angle_gt) in enumerate(valid_loader):
              img = img.to(device, non_blocking=True)
              landmark_gt = land_gt.to(device, non_blocking=True)
              angle_gt = angle_gt.to(device, non_blocking=True)
  
              landmark, _ = model(img)
  
              # compute the l2 loss
              landmark = landmark.squeeze()
              l2_diff = torch.sum((landmark_gt - landmark) ** 2, axis=1)
              loss = torch.mean(l2_diff)
              losses.append(loss.cpu().detach().numpy())
  
              # compute the accuracy
              landmark = landmark.cpu().detach().numpy()
              landmark = landmark.reshape(landmark.shape[0], -1, 2)
              landmark_gt = landmark_gt.cpu().detach().numpy()
              landmark_gt = landmark_gt.reshape(
                  landmark_gt.shape[0], -1, 2
              )
              _, nme_i = accuracy(landmark, landmark_gt)
              for item in nme_i:
                  nme.append(item)
  
      logger.info("===> Evaluate:")
      logger.info(
          "Eval set: Average loss: {:.4f} nme: {:.4f}".format(
              np.mean(losses), np.mean(nme)
          )
      )
      return np.mean(losses), np.mean(nme)
  
file_path: nni/examples/nas/legacy/oneshot/pfld/retrain.py
imports: from __future__ import absolute_import, division, print_function
  import argparse
  import logging
  import os
  import time
  import torch
  import torchvision
  import numpy
  from datasets import PFLDDatasets
  from lib.builder import search_space
  from lib.ops import PRIMITIVES
  from lib.utils import PFLDLoss, accuracy
  from nni.algorithms.nas.pytorch.fbnet import LookUpTable, NASConfig, supernet_sample
  from nni.nas.pytorch.utils import AverageMeter
  from torch.utils.data import DataLoader
label_desc: Use image node_id 1 for calling a global function with example usage: validate(model, auxiliarynet, valid_loader, device, logger) and returns: np,  np