def foreground_acc(inp, targ, bkg_idx=0, axis=1):
    """Computes non-background accuracy for multiclass segmentation"""
    targ = targ.squeeze(1)
    mask = targ != bkg_idx
    return (inp.argmax(dim=axis)[mask] == targ[mask]).float().mean()
