def _sort_preds(self, keypoints_pred, scores_pred, keypoints_gt):
        """Sort multi-instance predictions to best match the ground-truth.

        Args:
            keypoints_pred (np.ndarray): predictions in shape (N, K, D)
            scores (np.ndarray): predictions in shape (N, K)
            keypoints_gt (np.ndarray): ground-truth in shape (N, K, D)

        Returns:
            np.ndarray: Sorted predictions
        """
        assert keypoints_gt.shape == keypoints_pred.shape
        costs = np.linalg.norm(
            keypoints_gt[None] - keypoints_pred[:, None], ord=2,
            axis=3).mean(axis=2)
        match = Munkres().compute(costs)
        keypoints_pred_sorted = np.zeros_like(keypoints_pred)
        scores_pred_sorted = np.zeros_like(scores_pred)
        for i, j in match:
            keypoints_pred_sorted[i] = keypoints_pred[j]
            scores_pred_sorted[i] = scores_pred[j]

        return keypoints_pred_sorted, scores_pred_sorted
Sort multi-instance predictions to best match the ground-truth.

        Args:
            keypoints_pred (np.ndarray): predictions in shape (N, K, D)
            scores (np.ndarray): predictions in shape (N, K)
            keypoints_gt (np.ndarray): ground-truth in shape (N, K, D)

        Returns:
            np.ndarray: Sorted predictions
        
mmpose/tests/test_codecs/test_associative_embedding.py