code: def _clip_boxes(boxes, im_shape):
      """Clip boxes to image boundaries."""
      # x1 >= 0
      boxes[:, 0::4] = np.maximum(boxes[:, 0::4], 0)
      # y1 >= 0
      boxes[:, 1::4] = np.maximum(boxes[:, 1::4], 0)
      # x2 < im_shape[1]
      boxes[:, 2::4] = np.minimum(boxes[:, 2::4], im_shape[1] - 1)
      # y2 < im_shape[0]
      boxes[:, 3::4] = np.minimum(boxes[:, 3::4], im_shape[0] - 1)
      return boxes
  
file_path: CNTK/Examples/Image/Detection/FastRCNN/BrainScript/fastRCNN/test.py
imports: from __future__ import print_function
  import os, sys, cv2, numpy, pickle, heapq
  from .nms import nms
  from .utils.cython_nms import nms
  from .timer import Timer
  from cntk_helpers import im_detect, apply_nms
  from builtins import range
label_desc: Use image node_id 6 for calling a global function with example usage: _clip_boxes(boxes, im_shape) and returns: boxes