Hello,
in general, yes, but it is expensive in terms of memory. Doing several .backward calls (but only one optimizer .step) may be a more memory-efficient way produce the same result.
Best regards
Thomas