code: def mIoU(preds, label, cat, cat_miou, seg_classes):
      for i in range(preds.shape[0]):
          shape_iou = 0
          n = len(seg_classes[cat[i]])
          for cls in seg_classes[cat[i]]:
              pred_set = set(np.where(preds[i, :] == cls)[0])
              label_set = set(np.where(label[i, :] == cls)[0])
              union = len(pred_set.union(label_set))
              inter = len(pred_set.intersection(label_set))
              if union == 0:
                  shape_iou += 1
              else:
                  shape_iou += inter / union
          shape_iou /= n
          cat_miou[cat[i]][0] += shape_iou
          cat_miou[cat[i]][1] += 1
  
      return cat_miou
  
file_path: dgl/examples/pytorch/pointcloud/point_transformer/train_partseg.py
imports: import argparse
  import time
  from functools import partial
  import dgl
  import numpy
  import torch
  import torch.optim
  import tqdm
  from point_transformer import PartSegLoss, PointTransformerSeg
  from ShapeNet import ShapeNet
  from torch.utils.data import DataLoader
label_desc: Use image node_id 3 for calling a global function with example usage: mIoU(preds, label, cat, cat_miou, seg_classes) and returns: cat_miou