This is not a good place to use eval. Furthermore, you should use sets to separate the encoder parameters from the decoder parameters instead of id. With this in mind, a better way to write the first part is:
encode_params = set()
for i in range(5):
     module = getattr(model, 'conv_encode{}'.format(i+1))
     encode_params.update(module.parameters())

model_params = set(model.parameters())
decode_params = model_params - encode_params
 
optimizer = torch.optim.SGD([{'params': list(decode_params)},
                             {'params': list(encode_params), 'lr': base_lr / 10}], 
                            lr=base_lr, momentum=0.9)

Try to print everything that you suspect may cause the issue.
If you can’t solve the problem yourself, please provide some additional information so it’s easier for us to find a solution (the error’s stack trace would be helpful, and printing decode_params).