def get_instance_bbox(keypoints: np.ndarray,
                      keypoints_visible: Optional[np.ndarray] = None
                      ) -> np.ndarray:
    """Calculate the pseudo instance bounding box from visible keypoints. The
    bounding boxes are in the xyxy format.

    Args:
        keypoints (np.ndarray): Keypoint coordinates in shape (N, K, D)
        keypoints_visible (np.ndarray): Keypoint visibilities in shape
            (N, K)

    Returns:
        np.ndarray: bounding boxes in [N, 4]
    """
    bbox = np.zeros((keypoints.shape[0], 4), dtype=np.float32)
    for i in range(keypoints.shape[0]):
        if keypoints_visible is not None:
            visible_keypoints = keypoints[i][keypoints_visible[i] > 0]
        else:
            visible_keypoints = keypoints[i]
        if visible_keypoints.size == 0:
            continue

        bbox[i, :2] = visible_keypoints.min(axis=0)
        bbox[i, 2:] = visible_keypoints.max(axis=0)
    return bbox
Calculate the pseudo instance bounding box from visible keypoints. The
    bounding boxes are in the xyxy format.

    Args:
        keypoints (np.ndarray): Keypoint coordinates in shape (N, K, D)
        keypoints_visible (np.ndarray): Keypoint visibilities in shape
            (N, K)

    Returns:
        np.ndarray: bounding boxes in [N, 4]
    
mmpose/mmpose/codecs/utils/instance_property.py