Cannot calculate second order gradients even though `create_graph=True`

I think the problem in your code is:

for p in m.parameters():
  p = p - LR * p.grad

This does not modify p inplace ! It just assigns the result to a variable name p that you override just after. So you could remove these lines and your code would run the same.
This is why you don’t see the link.

Another issue you’re gonna face is that nn.Parameter() are built explicitly to be leaf Tensors (with no history) and so you won’t be able to change them with a Tensor you try to backprop through.

You can check the higher package to do this properly (they solve this problem of nn.Parameter for you). Otherwise, if you want to do it manually, you can find some info in this thread: How does one have the parameters of a model NOT BE LEAFS?