Thanks a lot for your responses.
This configuration seems to solve the problem:
        optimizer_encoder.zero_grad()
        optimizer_decoder.zero_grad()

        loss_ele.backward(retain_graph=True)
        loss_decoder.backward(retain_graph=True)

        optimizer_encoder.step()
        optimizer_decoder.step()

        # discriminator update
        optimizer_disc.zero_grad()
        lossD.backward()
        optimizer_disc.step()

BTW, should I still do “del lossD” after all optimization steps? What does it do?