Batch mapping #
A backend-independent recursion for applying an operation pointwise over the outer axis of a shape-typed reference. Eager and typed graph execution supply their own slicing, reshaping, and concatenation operations; the traversal itself remains shared.
Apply a reference-level operation independently to every entry of a leading axis.
The callbacks isolate the four structural operations needed by the recursion. Device backends may replace this reference traversal with a fused primitive when the fused operation has the same per-entry semantics.
The axis is split in half and each half is mapped recursively, so f still runs on entries
0, ..., n - 1 in order while every entry is sliced and concatenated once per level of a balanced
tree. Peeling one entry at a time would copy the remaining tail at every step.