TensorChainLAWS.take: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend as TensorChainLAWS Lines 62-69 of bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend&start_line=62&end_line=69 import Base import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward # Takes out of a newest-first log every contribution to id and accumulates # them into slot, oldest first; the others stay in the log, in order. def take(log: Log(), +id: Nat, slot: Gradient.Slot) -> Taken(): match log: case Nil{}: (Done{slot}, Nil{}) case Con{Backward.Contribution{+target, +shape, gradient}, rest}: sorted(target, shape, gradient, Nat.is_eq(id, target), take(rest, id, slot)) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/gradient.bend&name=Slot https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=Contribution https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend&name=Log https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend&name=Taken https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend&name=sorted