code: def bbox_crop(bbox, crop_box=None, allow_outside_center=True):
      """Crop bounding boxes according to slice area.
      This method is mainly used with image cropping to ensure bonding boxes fit
      within the cropped image.
  
      Parameters
      ----------
      bbox : numpy.ndarray
          Numpy.ndarray with shape (N, 4+) where N is the number of bounding boxes.
          The second axis represents attributes of the bounding box.
          Specifically, these are :math:`(x_{min}, y_{min}, x_{max}, y_{max})`,
          we allow additional attributes other than coordinates, which stay intact
          during bounding box transformations.
      crop_box : tuple
          Tuple of length 4. :math:`(x_{min}, y_{min}, width, height)`
      allow_outside_center : bool
          If `False`, remove bounding boxes which have centers outside cropping area.
      Returns
      -------
      numpy.ndarray
          Cropped bounding boxes with shape (M, 4+) where M <= N.
      """
      bbox = bbox.copy()
      if crop_box is None:
          return bbox
      if not len(crop_box) == 4:
          raise ValueError(
              "Invalid crop_box parameter, requires length 4, given {}".format(
                  str(crop_box)
              )
          )
      if sum([int(c is None) for c in crop_box]) == 4:
          return bbox
  
      l, t, w, h = crop_box
  
      left = l if l else 0
      top = t if t else 0
      right = left + (w if w else np.inf)
      bottom = top + (h if h else np.inf)
      crop_bbox = np.array((left, top, right, bottom))
  
      if allow_outside_center:
          mask = np.ones(bbox.shape[0], dtype=bool)
      else:
          centers = (bbox[:, :2] + bbox[:, 2:4]) / 2
          mask = (
              (crop_bbox[:2] <= centers) * (centers < crop_bbox[2:])
          ).all(axis=1)
  
      # transform borders
      bbox[:, :2] = np.maximum(bbox[:, :2], crop_bbox[:2])
      bbox[:, 2:4] = np.minimum(bbox[:, 2:4], crop_bbox[2:4])
      bbox[:, :2] -= crop_bbox[:2]
      bbox[:, 2:4] -= crop_bbox[:2]
  
      mask = mask * (bbox[:, :2] < bbox[:, 2:4]).all(axis=1)
      bbox = bbox[mask]
      return bbox
  
file_path: mxnet/python/mxnet/gluon/contrib/data/vision/transforms/bbox/utils.py
imports: from __future__ import division
  import random
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: bbox_crop(bbox, crop_box, allow_outside_center) and returns: bbox, bbox, bbox