code: def accuracy_func_provider():
      """Provide function that calculates accuracies."""
      args = get_args()
      data_path = args.data_path
      crop_size = (args.img_h, args.img_w)
  
      # Build dataloaders.
      val_data_path = data_path[1]
      normalize = transforms.Normalize(
          mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]
      )
      transform_val = transforms.Compose(
          [
              transforms.Resize(crop_size),
              transforms.CenterCrop(crop_size),
              transforms.ToTensor(),
              normalize,
          ]
      )
      dataset = datasets.ImageFolder(
          root=val_data_path, transform=transform_val
      )
  
      dataloader = build_data_loader(
          dataset,
          args.micro_batch_size,
          num_workers=args.num_workers,
          drop_last=(mpu.get_data_parallel_world_size() > 1),
          shuffle=False,
      )
  
      def metrics_func(model, epoch):
          print_rank_0("calculating metrics ...")
          correct, total = calculate_correct_answers(
              model, dataloader, epoch
          )
          percent = float(correct) * 100.0 / float(total)
          print_rank_last(
              " >> |epoch: {}| overall: correct / total = {} / {} = "
              "{:.4f} %".format(epoch, correct, total, percent)
          )
  
      return metrics_func
  
file_path: megatron-lm/tasks/vision/classification/eval_utils.py
imports: import os
  from functools import partial
  import torch
  from megatron import get_args
  from megatron import print_rank_0, print_rank_last
  from megatron.core import mpu
  from megatron.schedules import get_forward_backward_func
  from tasks.vision.finetune_utils import build_data_loader
  from tasks.vision.finetune_utils import process_batch
  from torchvision import datasets, transforms
label_desc: Use image node_id 1 for calling a global function with example usage: accuracy_func_provider() and returns: metrics_func