Have you tried invoking the backward function with the feature vector i.e. backward(x) instead of backward()?
I wrote a custom class which inherits autograd Function and the backward call defined as “def backward(ctx, grad_output):” . It returns the J*grad_out which is of same dimension as grad_out.