code: def bbox_overlaps_3D(boxes1, boxes2):
      """Computes IoU overlaps between two sets of boxes.
      boxes1, boxes2: [N, (y1, x1, y2, x2, z1, z2)].
      """
      # 1. Tile boxes2 and repeate boxes1. This allows us to compare
      # every boxes1 against every boxes2 without loops.
      # TF doesn't have an equivalent to np.repeate() so simulate it
      # using tf.tile() and tf.reshape.
      boxes1_repeat = boxes2.size()[0]
      boxes2_repeat = boxes1.size()[0]
      boxes1 = boxes1.repeat(1, boxes1_repeat).view(-1, 6)
      boxes2 = boxes2.repeat(boxes2_repeat, 1)
  
      # 2. Compute intersections
      b1_y1, b1_x1, b1_y2, b1_x2, b1_z1, b1_z2 = boxes1.chunk(6, dim=1)
      b2_y1, b2_x1, b2_y2, b2_x2, b2_z1, b2_z2 = boxes2.chunk(6, dim=1)
      y1 = torch.max(b1_y1, b2_y1)[:, 0]
      x1 = torch.max(b1_x1, b2_x1)[:, 0]
      y2 = torch.min(b1_y2, b2_y2)[:, 0]
      x2 = torch.min(b1_x2, b2_x2)[:, 0]
      z1 = torch.max(b1_z1, b2_z1)[:, 0]
      z2 = torch.min(b1_z2, b2_z2)[:, 0]
      zeros = Variable(torch.zeros(y1.size()[0]), requires_grad=False)
      if y1.is_cuda:
          zeros = zeros.cuda()
      intersection = (
          torch.max(x2 - x1, zeros)
          * torch.max(y2 - y1, zeros)
          * torch.max(z2 - z1, zeros)
      )
  
      # 3. Compute unions
      b1_volume = (b1_y2 - b1_y1) * (b1_x2 - b1_x1) * (b1_z2 - b1_z1)
      b2_volume = (b2_y2 - b2_y1) * (b2_x2 - b2_x1) * (b2_z2 - b2_z1)
      union = b1_volume[:, 0] + b2_volume[:, 0] - intersection
  
      # 4. Compute IoU and reshape to [boxes1, boxes2]
      iou = intersection / union
      overlaps = iou.view(boxes2_repeat, boxes1_repeat)
      return overlaps
  
imports: import numpy
  import scipy.misc
  import scipy.ndimage
  import torch
  from torch.autograd import Variable
  import torch.nn
label_desc: Use image node_id 16 for calling a global function with example usage: bbox_overlaps_3D(boxes1, boxes2) and returns: overlaps