int32 array [B, L].
OptionalvalidLengths: number[]logits [B, L, V] (caller owns; dispose when done).
When validLengths is omitted (or every row is full-length L) the batch
has no padding and the caches read causally — the B=1 result is
bit-identical to the original trainer. When some row is shorter than L,
the caches read under the padding-aware batched mask.
Run a full-sequence forward for training.