code: def _mask_aggregation(
      bbox, seg_prob, seg_weight, size, binary_thresh
  ):
      assert bbox.shape[0] == len(seg_prob)
      assert bbox.shape[0] == seg_weight.shape[0]
  
      aggregated_msk = np.zeros(size, dtype=np.float32)
      for bb, seg_pb, seg_w in zip(bbox, seg_prob, seg_weight):
          bb = np.round(bb).astype(np.int32)
          y_min, x_min, y_max, x_max = bb
          if y_max - y_min > 0 and x_max - x_min > 0:
              seg_pb = resize(
                  seg_pb.astype(np.float32)[None],
                  (y_max - y_min, x_max - x_min),
              )
              seg_m = (seg_pb >= binary_thresh).astype(np.float32)[0]
              aggregated_msk[y_min:y_max, x_min:x_max] += seg_m * seg_w
  
      y_indices, x_indices = np.where(aggregated_msk >= binary_thresh)
      if len(y_indices) == 0 or len(x_indices) == 0:
          return None, None
      else:
          y_max = y_indices.max() + 1
          y_min = y_indices.min()
          x_max = x_indices.max() + 1
          x_min = x_indices.min()
  
          aggregated_bb = np.array(
              [y_min, x_min, y_max, x_max], dtype=np.float32
          )
          aggregated_cmsk = aggregated_msk[y_min:y_max, x_min:x_max]
          return aggregated_cmsk[None], aggregated_bb[None]
  
imports: import numpy
  from chainercv.transforms.image.resize import resize
  from chainercv.utils.bbox.bbox_iou import bbox_iou
  from chainercv.utils import non_maximum_suppression
label_desc: Use image node_id 1 for calling a global function with example usage: _mask_aggregation(bbox, seg_prob, seg_weight, size, binary_thresh) and returns: None,  None, aggregated_cmsk,  aggregated_bb