Solved by albanD in post #4 
              
              
                Hi, 
You don’t have to do each parameter one by one, you can give all the params/grads as tuples. 
You get all zeros because your function f does not use the inputs x to compute the output. 
You can do something like this to use the autograd API with torch.nn: 
# Utilities to make nn.Module function…