code: def bbox_clip_xyxy(xyxy, width, height):
      """Clip bounding box with format (xmin, ymin, xmax, ymax) to specified boundary.
  
      All bounding boxes will be clipped to the new region `(0, 0, width, height)`.
  
      Parameters
      ----------
      xyxy : list, tuple or numpy.ndarray
          The bbox in format (xmin, ymin, xmax, ymax).
          If numpy.ndarray is provided, we expect multiple bounding boxes with
          shape `(N, 4)`.
      width : int or float
          Boundary width.
      height : int or float
          Boundary height.
  
      Returns
      -------
      type
          Description of returned object.
  
      """
      if isinstance(xyxy, (tuple, list)):
          if not len(xyxy) == 4:
              raise IndexError(
                  "Bounding boxes must have 4 elements, given {}".format(
                      len(xyxy)
                  )
              )
          x1 = np.minimum(width - 1, np.maximum(0, xyxy[0]))
          y1 = np.minimum(height - 1, np.maximum(0, xyxy[1]))
          x2 = np.minimum(width - 1, np.maximum(0, xyxy[2]))
          y2 = np.minimum(height - 1, np.maximum(0, xyxy[3]))
          return x1, y1, x2, y2
      elif isinstance(xyxy, np.ndarray):
          if not xyxy.size % 4 == 0:
              raise IndexError(
                  "Bounding boxes must have n * 4 elements, given {}".format(
                      xyxy.shape
                  )
              )
          x1 = np.minimum(width - 1, np.maximum(0, xyxy[:, 0]))
          y1 = np.minimum(height - 1, np.maximum(0, xyxy[:, 1]))
          x2 = np.minimum(width - 1, np.maximum(0, xyxy[:, 2]))
          y2 = np.minimum(height - 1, np.maximum(0, xyxy[:, 3]))
          return np.hstack((x1, y1, x2, y2))
      else:
          raise TypeError(
              "Expect input xywh a list, tuple or numpy.ndarray, given {}".format(
                  type(xyxy)
              )
          )
  
imports: from __future__ import division
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: bbox_clip_xyxy(xyxy, width, height) and returns: x1,  y1,  x2,  y2, np