Ok after trying a few things.


In order to make sure func would not be included in the Autograd graph, I all had to do was to pass x.data to it instead of x:
loss_y = second_loss(func(x.data), y)


This way I won’t have to think if I should return None for it backward or not, backward will simply not be called by autograd.

It is Ok if we only bind forward for a cuda extension, it works just fine