import torch


def compute_accuracy(logits, labels, mask):
    """Compute the accuracy"""
    logits = logits[mask]
    labels = labels[mask]
    _, indices = torch.max(logits, dim=1)
    correct = torch.sum(indices == labels)
    return correct.item() * 1.0 / len(labels)