def grad_at
bendtorch-core@0.1.0.0 · src/autograd/tensor_backward.bend:1018
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as TensorBackward
import Base
1018def grad_at(entries: List<&1, Entry>, +count: Nat, +id: Nat, same: Bool) -> Graded():
1019 match entries count same:
1020 case Nil{} count same:
1021 (Nil{}, Fail{UnknownNode{}})
1022 case Con{entry, rest} 0n same:
1023 (entry <> rest, Fail{UnknownNode{}})
1024 case Con{entry, rest} 1n+below True{}:
1025 found_grad(entry, rest)
1026 case Con{entry, rest} 1n+below False{}:
1027 prepend_graded(entry, grad_at(rest, below, id, at_head(below, id)))