code: def iou(preds, labels, C, EMPTY=1., ignore=None, per_image=False):
      
      if not per_image:
          preds, labels = (preds,), (labels,)
      ious = []
      for pred, label in zip(preds, labels):
          iou = []    
          for i in range(C):
              if i != ignore: # The ignored label is sometimes among predicted classes (ENet - CityScapes)
                  intersection = ((label == i) & (pred == i)).sum()
                  union = ((label == i) | ((pred == i) & (label != ignore))).sum()
                  if not union:
                      iou.append(EMPTY)
                  else:
                      iou.append(float(intersection) / union)
          ious.append(iou)
      ious = map(mean, zip(*ious)) # mean accross images if per_image
      return 100 * np.array(ious)
docs: Array of IoU for each (non ignored) class