Yes, your understanding is correct. The parameters of the newly created Residual modules won’t be part of the optimizer and will never be updated. Even if the optimizer would somehow update them (or you manually), you would recreate a new module in the next forward pass, which would again use random parameters.
To fix this issue you should initialize this module in the __init__ (as is done with other layers) and just use it in the forward.
If the follow-up question is related to this one, let’s keep it in this thread.