Ahhh! So it is essential that I create separate instances of encoder1 and encoder2?
What I previously did was
class decoder(nn.Module):
            #code

       forward(inp1, inp2):
             #code
             return output1, output2

class encoder(nn.Module):
            #code

       forward(inp1, inp2):
             #code
             return output1, output2

#for both first and second autoencoder
encoder=encoder()
decoder=decoder()

So how does backprop work for this?