You cannot call nn.ModuleList directly, as it’s used as a container to store other modules.
If you want to call encoder with an input, you could either try to wrap all modules into nn.Sequential or apply the loop over all modules manually.