def nll_rows
import bendtorch@1.3.0.0/main.bend as Bendtorchimport Base
3292# the sum of the picked log-probabilities (in row order, from +0.0), and the gradient (-1/n at each label)
3293def nll_rows(left: Nat, labels: List<&2, Nat>, +i: U32, +c: Nat, +v: F32, st: NS) -> NS:
3294 match left labels st:
3295 case 1n+q Con{+y, t} NS{lp, g, acc}:
3296 nll_rows(q, t, (i + 1 : U32), c, v, nll_one(Nat.is_le(1n+y, c), ((i * U32.from_nat(c) : U32) + U32.from_nat(y) : U32), v, acc, lp, g))
3297 case _ _ st:
3298 st