def get_diagonal_lengths(keypoints: np.ndarray,
                         keypoints_visible: Optional[np.ndarray] = None
                         ) -> np.ndarray:
    """Calculate the diagonal length of instance bounding box from visible
    keypoints.

    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 box diagonal length in [N]
    """
    pseudo_bbox = get_instance_bbox(keypoints, keypoints_visible)
    pseudo_bbox = pseudo_bbox.reshape(-1, 2, 2)
    h_w_diff = pseudo_bbox[:, 1] - pseudo_bbox[:, 0]
    diagonal_length = np.sqrt(np.power(h_w_diff, 2).sum(axis=1))

    return diagonal_length
Calculate the diagonal length of instance bounding box from visible
    keypoints.

    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 box diagonal length in [N]
    
mmpose/mmpose/codecs/utils/instance_property.py