Solved by dashesy in post #2 
              
              
                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 simpl…