def first_of
bendtorch-core@0.1.0.0 · src/autograd/tensor_vjp_LAWS.bend:77
import bendtorch-core@0.1.0.0/src/autograd/tensor_vjp_LAWS.bend as TensorVjpLAWS
import Base
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward
77
78def first_of(pass: Backward.Pass) -> Maybe<&1, Backward.Contribution>:
79 Backward.Pass{saved, g, contributions} = pass
80 match contributions:
81 case Fail{error}:
82 None{}
83 case Done{Nil{}}:
84 None{}
85 case Done{Con{first, Nil{}}}:
86 None{}
87 case Done{Con{first, Con{second, Nil{}}}}:
88 Some{first}
89 case Done{Con{first, Con{second, Con{other, rest}}}}:
90 None{}