original_docstring: 
      Clip boxes to image boundaries.
      
docstring: Clip boxes to image boundaries.
docstring_tokens: Clip boxes to image boundaries .
code: def clip_boxes(boxes, im_shape):
      """
      Clip boxes to image boundaries.
      """
      boxes = np.asarray(boxes)
      if boxes.shape[0] == 0:
          return boxes
      boxes = np.copy(boxes)
      # x1 >= 0
      boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0)
      # y1 >= 0
      boxes[:, 1::4] = np.maximum(np.minimum(boxes[:, 1::4], im_shape[0] - 1), 0)
      # x2 < im_shape[1]
      boxes[:, 2::4] = np.maximum(np.minimum(boxes[:, 2::4], im_shape[1] - 1), 0)
      # y2 < im_shape[0]
      boxes[:, 3::4] = np.maximum(np.minimum(boxes[:, 3::4], im_shape[0] - 1), 0)
      return boxes
code_tokens: def clip_boxes ( boxes , im_shape ) : boxes = np . asarray ( boxes ) if boxes . shape [ 0 ] == 0 : return boxes boxes = np . copy ( boxes ) boxes [ : , 0 : : 4 ] = np . maximum ( np . minimum ( boxes [ : , 0 : : 4 ] , im_shape [ 1 ] - 1 ) , 0 ) boxes [ : , 1 : : 4 ] = np . maximum ( np . minimum ( boxes [ : , 1 : : 4 ] , im_shape [ 0 ] - 1 ) , 0 ) boxes [ : , 2 : : 4 ] = np . maximum ( np . minimum ( boxes [ : , 2 : : 4 ] , im_shape [ 1 ] - 1 ) , 0 ) boxes [ : , 3 : : 4 ] = np . maximum ( np . minimum ( boxes [ : , 3 : : 4 ] , im_shape [ 0 ] - 1 ) , 0 ) return boxes
short_docstring: Clip boxes to image boundaries.
short_docstring_tokens: Clip boxes to image boundaries .
comment: """
      Clip boxes to image boundaries.
      """$SEP$# x1 >= 0$SEP$# y1 >= 0$SEP$# x2 < im_shape[1]$SEP$# y2 < im_shape[0]