code: def test():
      model.eval()
      test_loss = 0.0
      test_accuracy = 0.0
      for data, target in test_loader:
          if args.cuda:
              data, target = data.cuda(), target.cuda()
          output = model(data)
          # sum up batch loss
          test_loss += F.nll_loss(
              output, target, size_average=False
          ).item()
          # get the index of the max log-probability
          pred = output.data.max(1, keepdim=True)[1]
          test_accuracy += (
              pred.eq(target.data.view_as(pred)).cpu().float().sum()
          )
  
      # Horovod: use test_sampler to determine the number of examples in
      # this worker's partition.
      test_loss /= len(test_sampler)
      test_accuracy /= len(test_sampler)
  
      # Horovod: average metric values across workers.
      test_loss = metric_average(test_loss, "avg_loss")
      test_accuracy = metric_average(test_accuracy, "avg_accuracy")
  
      # Horovod: print output only on first rank.
      if hvd.rank() == 0:
          print(
              "\nTest set: Average loss: {:.4f}, Accuracy: {:.2f}%\n".format(
                  test_loss, 100.0 * test_accuracy
              )
          )
  
file_path: horovod/examples/elastic/pytorch/pytorch_mnist_elastic.py
imports: import argparse
  import os
  from filelock import FileLock
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torchvision import datasets, transforms
  import torch.utils.data.distributed
  import horovod.torch
label_desc: Use image node_id 3 for calling a global function with example usage: test() without return types