Hi,
grad_output  is the gradient wrt to the output of the forward, so in this case dl/dy.
And yes the formula looks good.
In the implementation,

for the forward, even though you can go through numpy, I don’t think you should here: all these ops just work on pytorch.
For the backward, you should write it in a differentiable manner in case you try to access grad of grad in there. If you don’t, use from torch.autograd.function import once_differentiable as another decorator for the backward.
Same point for the backward that I don’t see any reason to use numpy, even if you make it once_differentiable.