I wonder this topic too. There is no explicit connection between optimizer and loss objects in a program. Are they related implicitly via global variables i.e. loss.backward() data recorded somewhere?
I suppose there should be more obvious call like this:
optimzer.step(loss)