Thank you for your guidance,It works.I may have understood what you mean,
In the process of back propagation, the state of the original node should not be changed…
w=w.squeeze()will change w’s  requires_grad=True become to grad_fn=<SqueezeBackward0>.I’ll remember to look at the state of the variable first.
Finally, thank you again,have a nice day.