def offset
import bendtorch-core@0.1.0.0/src/tensor/permute_build.bend as PermuteBuildimport Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
94# `Shape.offset` of the scattered coordinates, each through U32 and back as
95# `Shape.words` and `Shape.naturals` take it.
96def offset(+strides: List<&2, Nat>, +picks: List<&2, Pick>, +x: Nat) -> Nat:
97 match strides picks:
98 case +stride <> rest +pick <> others:
99 Nat.add(Nat.mul(U32.to_nat(U32.from_nat(coordinate(pick, x))), stride), offset(rest, others, x))
100 case strides picks:
101 0n