softpipe: Factor gradient evaluation out of the lambda evaluation