code: def iou_single(a, b, mask, n_class):
      EPS = 1e-6
      valid = mask == 1
      a = a[valid]
      b = b[valid]
      miou = []
  
      # iou of each class
      for i in range(n_class):
          inter = paddle.cast(((a == i) & (b == i)), "float32")
          union = paddle.cast(((a == i) | (b == i)), "float32")
  
          miou.append(paddle.sum(inter) / (paddle.sum(union) + EPS))
      miou = sum(miou) / len(miou)
      return miou
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import nn
  import paddle.nn.functional
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: iou_single(a, b, mask, n_class) and returns: miou