code: def test():
      model.eval()
      test_loss = 0
      correct = 0
      for data, target in test_loader:
          if args.cuda:
              data, target = data.cuda(), target.cuda()
          data, target = Variable(data, volatile=True), Variable(target)
          output = model(data)
          test_loss += F.nll_loss(
              output, target, size_average=False
          ).data[
              0
          ]  # sum up batch loss
          pred = output.data.max(1, keepdim=True)[
              1
          ]  # get the index of the max log-probability
          correct += (
              pred.eq(target.data.view_as(pred)).long().cpu().sum()
          )
  
      test_loss /= len(test_loader.dataset)
      print(
          "\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\n".format(
              test_loss,
              correct,
              len(test_loader.dataset),
              100.0 * correct / len(test_loader.dataset),
          )
      )
  
file_path: dynet/examples/mnist/basic-mnist-benchmarks/mnist_pytorch.py
imports: from __future__ import print_function
  import argparse
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torchvision import datasets, transforms
  from torch.autograd import Variable
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: test() without return types