The example that you showed has a problem with it.
Indeed, when you do list(model.parameters())[0], you are taking a reference of the tensor.
Try adding a clone() instead
a = list(self.parameters())[0].clone()
loss.backward()
self.optimizer.step()
b = list(self.parameters())[0].clone()
torch.equal(a.data, b.data)