If you want to get the parameters of all modules, you could also use an nn.ModuleList and just pass the .parameters() of this ModuleList to the optimizer.
Using this approach would also make sure to push all submodules to the CPU/GPU if needed.