samarth-robo:

The code for nn.Module.__setattr__() suggests that it will remove duplicate parameters passed to it, so it seems to me that
opt = optim.Adam(list(encoder.parameters()) + list(decoder.parameters()))



You can still have two modules with dictionaries as parameters. Both modules will have once each of its parameters in the dict, but if the two dictionaries have common parameters, it will raise error
ValueError: some parameters appear in more than one parameter group