def bbox_flip(bboxes, img_shape):
    """Flip bboxes horizontally.

    Args:
        bboxes(ndarray): shape (..., 4*k)
        img_shape(tuple): (height, width)
    """
    assert bboxes.shape[-1] % 4 == 0
    w = img_shape[1]
    flipped = bboxes.copy()
    flipped[(...), 0::4] = w - bboxes[(...), 2::4] - 1
    flipped[(...), 2::4] = w - bboxes[(...), 0::4] - 1
    return flipped
