I think so. And it’s easily verifiable, you can proceed as @Ali1234  says, but it can also be done without the need to calculate an intermediate loss.
For example you can check the following quantity before and after optimizer.step() :
norm_check = (sum([p.norm(p=2).item() ** 2 for p in model2.parameters()]) ** 0.5

Or after loss.backward() you can check the gradient of one of the parameters of ``model2```
next(model2.parameters()).grad

There are some that are certainly more efficient…