Why does Op.L_op(inputs, outputs, output_gradients) need outputs argument?
Here is the method signature description Creating a new Op: Python implementation — PyTensor dev documentation . This seemingly older page Ops — PyTensor dev documentation does not have this argument in the analogous method Op.grad(inputs, output_gradients) . I looked into PyTensor code and found no essential use of outputs (maybe once I saw a reference to its type or other metadata, maybe not). This leaves the question: what is the reason for including outputs? What is its semantics? Is this for optimisation? If computation of gradient requires to evaluate the function value again (as in \mathrm{d}\,e^{x^2}), would not graph re-writer automatically merge the nodes or something?
(By the way, in case of a custom Yes, of course, as shown in the first link: Op, can it be self-referential? That is, is there a way to refer to MyOp from inside MyOp.L_op()?outputs = self(inputs))