code: def iou(a, b, mask, n_class=2, reduce=True):
      batch_size = a.shape[0]
  
      a = a.reshape((batch_size, -1))
      b = b.reshape((batch_size, -1))
      mask = mask.reshape((batch_size, -1))
  
      iou = paddle.zeros((batch_size,), dtype="float32")
      for i in range(batch_size):
          iou[i] = iou_single(a[i], b[i], mask[i], n_class)
  
      if reduce:
          iou = paddle.mean(iou)
      return iou
  
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 4 for calling a global function with example usage: iou(a, b, mask, n_class, reduce) and returns: iou