def crop(boxes, top, left, height, width, bounding_box_format="xyxy"):
    """Crops bounding boxes based on the given offsets and dimensions.

    This function crops bounding boxes to a specified region defined by
    `top`, `left`, `height`, and `width`. The boxes are first converted to
    `xyxy` format, cropped, and then returned.

    Args:
        boxes: The bounding boxes to crop.  A NumPy array or tensor of shape
            `(N, 4)` or `(batch_size, N, 4)`.
        top: The vertical offset of the top-left corner of the cropping region.
        left: The horizontal offset of the top-left corner of the cropping
            region.
        height: The height of the cropping region. Defaults to `None`.
        width: The width of the cropping region. Defaults to `None`.
        bounding_box_format: The format of the input bounding boxes. Defaults to
            `"xyxy"`.

    Returns:
        The cropped bounding boxes.

    Example:
    ```python
    boxes = np.array([[10, 20, 50, 60], [70, 80, 100, 120]])  # xyxy format
    cropped_boxes = keras.utils.bounding_boxes.crop(
        boxes, bounding_box_format="xyxy", top=10, left=20, height=40, width=30
    )  # Cropping a 30x40 region starting at (20, 10)
    print(cropped_boxes)
    # Expected output:
    # array([[ 0., 10., 30., 50.],
    #        [50., 70., 80., 110.]])
    """
    if bounding_box_format != "xyxy":
        raise NotImplementedError
    box_utils = BoundingBox()
    # Switch to tensorflow backend if we are in tf.data pipe
    if backend_utils.in_tf_graph():
        box_utils.backend.set_backend("tensorflow")
    outputs = box_utils.crop(boxes, top, left, height, width)
    box_utils.backend.reset()
    return outputs
Crops bounding boxes based on the given offsets and dimensions.

    This function crops bounding boxes to a specified region defined by
    `top`, `left`, `height`, and `width`. The boxes are first converted to
    `xyxy` format, cropped, and then returned.

    Args:
        boxes: The bounding boxes to crop.  A NumPy array or tensor of shape
            `(N, 4)` or `(batch_size, N, 4)`.
        top: The vertical offset of the top-left corner of the cropping region.
        left: The horizontal offset of the top-left corner of the cropping
            region.
        height: The height of the cropping region. Defaults to `None`.
        width: The width of the cropping region. Defaults to `None`.
        bounding_box_format: The format of the input bounding boxes. Defaults to
            `"xyxy"`.

    Returns:
        The cropped bounding boxes.

    Example:
    ```python
    boxes = np.array([[10, 20, 50, 60], [70, 80, 100, 120]])  # xyxy format
    cropped_boxes = keras.utils.bounding_boxes.crop(
        boxes, bounding_box_format="xyxy", top=10, left=20, height=40, width=30
    )  # Cropping a 30x40 region starting at (20, 10)
    print(cropped_boxes)
    # Expected output:
    # array([[ 0., 10., 30., 50.],
    #        [50., 70., 80., 110.]])
    
keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/converters.py