def foreground_acc(input, target, void_code):
    """Computes non-background accuracy, e.g. camvid for multiclass segmentation"""
    target = target.squeeze(1)
    mask = target != void_code
    return (input.argmax(dim=1)[mask] == target[mask]).float().mean()
