def METHOD_NAME(confmat: Tensor) -> Tensor:
    """Compute the expected frequenceis from the provided confusion matrix."""
    margin_sum_rows, margin_sum_cols = confmat.sum(1), confmat.sum(0)
    return torch.einsum("r, c -> rc", margin_sum_rows, margin_sum_cols) / confmat.sum()