import torch


def accuracy(logits, labels):

    """
    Compute accuracy of given forward pass through network.

    Parameters:
    - - - - -
    logits: torch tensor
        output of single network forward pass
    labels: torch tensor
        ground truth class of each sample

    Returns:
    - - - -
    float scalar of network prediction accuracy

    """

    _, indices = torch.max(logits, dim=1)
    correct = torch.sum(indices == labels)
    
    return correct.item() * 1.0 / len(labels)