code: def clip_to_window(window, boxes):
      """
      window: (y1, x1, y2, x2) / 3D: (z1, z2). The window in the image we want to clip to.
      boxes: [N, (y1, x1, y2, x2)]  / 3D: (z1, z2)
      """
      boxes[:, 0] = boxes[:, 0].clamp(
          float(window[0]), float(window[2])
      )
      boxes[:, 1] = boxes[:, 1].clamp(
          float(window[1]), float(window[3])
      )
      boxes[:, 2] = boxes[:, 2].clamp(
          float(window[0]), float(window[2])
      )
      boxes[:, 3] = boxes[:, 3].clamp(
          float(window[1]), float(window[3])
      )
  
      if boxes.shape[1] > 5:
          boxes[:, 4] = boxes[:, 4].clamp(
              float(window[4]), float(window[5])
          )
          boxes[:, 5] = boxes[:, 5].clamp(
              float(window[4]), float(window[5])
          )
  
      return boxes
  
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 18 for calling a global function with example usage: clip_to_window(window, boxes) and returns: boxes