function loss(model, data; average=true)
    sum = cnt = 0
    for args in data
        (loss,count) = model(args...; average=false)
        sum += loss
        cnt += count
    end
    average ? sum / cnt : (sum,cnt)
end
