def accuracy(labels, logits, idx):
    """ Compute the accuracy for a set of nodes.

    Parameters
    ----------
    labels: torch.Tensor [n]
        The ground-truth labels for all nodes.
    logits: torch.Tensor, [n, nc]
        Logits for all nodes.
    idx: array-like [?]
        The indices of the nodes for which to compute the accuracy .

    Returns
    -------
    accuracy: float
        The accuracy.
    """
    return (labels[idx] == logits[idx].argmax(1)).sum().item() / len(idx)