code: def test_classification(model, test_loader, criterion, cfg, file):
      """Task of testing video classification"""
      batch_time = AverageMeter()
      data_time = AverageMeter()
      losses = AverageMeter()
      top1 = AverageMeter()
      top5 = AverageMeter()
      model.eval()
  
      end = time.time()
      final_result = []
  
      with torch.no_grad():
          for step, (
              inputs,
              labels,
              ids,
              chunk_nb,
              split_nb,
          ) in enumerate(test_loader):
              data_time.update(time.time() - end)
              val_batch = inputs.cuda()
              val_label = labels.cuda()
              outputs = model(val_batch)
              loss = criterion(outputs, val_label)
  
              for i in range(outputs.size(0)):
                  string = "{} {} {} {} {}\n".format(
                      ids[i],
                      str(outputs.data[i].cpu().numpy().tolist()),
                      str(int(labels[i].cpu().numpy())),
                      str(int(chunk_nb[i].cpu().numpy())),
                      str(int(split_nb[i].cpu().numpy())),
                  )
                  final_result.append(string)
  
              prec1, prec5 = accuracy(
                  outputs.data, val_label, topk=(1, 5)
              )
              losses.update(loss.item(), val_batch.size(0))
              top1.update(prec1.item(), val_batch.size(0))
              top5.update(prec5.item(), val_batch.size(0))
              batch_time.update(time.time() - end)
              end = time.time()
              if (
                  step % cfg.CONFIG.LOG.DISPLAY_FREQ == 0
                  and cfg.DDP_CONFIG.GPU_WORLD_RANK == 0
              ):
                  print("----Testing----")
                  print_string = "Epoch: [{0}][{1}/{2}]".format(
                      0, step + 1, len(test_loader)
                  )
                  print(print_string)
                  print_string = "data_time: {data_time:.3f}, batch time: {batch_time:.3f}".format(
                      data_time=data_time.val, batch_time=batch_time.val
                  )
                  print(print_string)
                  print_string = "loss: {loss:.5f}".format(
                      loss=losses.avg
                  )
                  print(print_string)
                  print_string = "Top-1 accuracy: {top1_acc:.2f}%, Top-5 accuracy: {top5_acc:.2f}%".format(
                      top1_acc=top1.avg, top5_acc=top5.avg
                  )
                  print(print_string)
      if not os.path.exists(file):
          os.mknod(file)
      with open(file, "w") as f:
          f.write("{}, {}\n".format(top1.avg, top5.avg))
          for line in final_result:
              f.write(line)
  
file_path: gluon-cv/gluoncv/torch/utils/task_utils/classification.py
imports: import os
  import logging
  import time
  import numpy
  import torch
  from ..utils import AverageMeter, accuracy
label_desc: Use image node_id 3 for calling a global function with example usage: test_classification(model, test_loader, criterion, cfg, file) without return types