is zero_grad working? since you are not registering the encoder and decoder etc with the Module in any way, (I think?), so zero_grad wont zero their gradients?  Do you need to somehow register the modules into the nn.Module parent class?