Thanks for your reply.
But even I pass the retain_variables=True to backward,  y.grad is still all zero.
hooks  look interesting, but is there anyway I can return the gradient rather than modify or print it?