code: def calculate_iou(hist_data):
      acc = np.diag(hist_data).sum() / hist_data.sum()
      acc_cls = np.diag(hist_data) / hist_data.sum(axis=1)
      acc_cls = np.nanmean(acc_cls)
      divisor = (
          hist_data.sum(axis=1)
          + hist_data.sum(axis=0)
          - np.diag(hist_data)
      )
      iu = np.diag(hist_data) / divisor
      return iu, acc, acc_cls
  
file_path: megatron-lm/tasks/vision/segmentation/finetune_segformer.py
imports: import numpy
  import torch
  import torch.nn.functional
  from functools import partial
  from megatron import get_args, get_timers
  from megatron import print_rank_0, print_rank_last
  from megatron.core import mpu
  from tasks.vision.finetune_utils import finetune
  from tasks.vision.finetune_utils import build_data_loader
  from megatron.utils import average_losses_across_data_parallel_group
  from megatron.schedules import get_forward_backward_func
  from tasks.vision.segmentation.data import build_train_valid_datasets
  from tasks.vision.segmentation.seg_models import SegformerSegmentationModel
  from megatron.model.vision.utils import resize
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_iou(hist_data) and returns: iu,  acc,  acc_cls