Thanks for this solution, but it seems that it only works for pytorch with version higher than 1.8 (otherwise there is no input argument named `inputs’ for backward()). Is there any other elegant solution to specify the scope of gradients when doing backward()?