code: def clip_boxes(boxes, shape):
      
      orig_shape = boxes.shape
      boxes = boxes.reshape([-1, 4])
      h, w = shape
      boxes[:, [0, 1]] = np.maximum(boxes[:, [0, 1]], 0)
      boxes[:, 2] = np.minimum(boxes[:, 2], w)
      boxes[:, 3] = np.minimum(boxes[:, 3], h)
      return boxes.reshape(orig_shape)
docs: Args:
          boxes: (...)x4, float
          shape: h, w