code: def test(model, device, test_loader):
      model.eval()
      test_loss = 0
      correct = 0
      count = 0
      with torch.no_grad():
          for row in test_loader:
              data, target = row["image"].to(device), row["digit"].to(
                  device
              )
              output = model(data)
              test_loss += F.nll_loss(
                  output, target, reduction="sum"
              ).item()  # sum up batch loss
              pred = output.max(1, keepdim=True)[
                  1
              ]  # get the index of the max log-probability
              correct += pred.eq(target.view_as(pred)).sum().item()
              count += data.shape[0]
  
      test_loss /= count
      print(
          "\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\n".format(
              test_loss, correct, count, 100.0 * correct / count
          )
      )
  
file_path: petastorm/examples/mnist/pytorch_example.py
imports: from __future__ import division, print_function
  import argparse
  import pyarrow
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torchvision import transforms
  from examples.mnist import DEFAULT_MNIST_DATA_PATH
  from petastorm import make_reader, TransformSpec
  from petastorm.pytorch import DataLoader
label_desc: Use image node_id 2 for calling a global function with example usage: test(model, device, test_loader) without return types