Hi
No, this gives the following error.
i use the retain graph =true  because to avoid freeing up the grad applied to the encoder weights and decoder weights… so to avoid the mismatch of weight data when the second loss is applied
RuntimeError: Trying to backward through the graph a second time (or directly access saved variables after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved variables after calling backward.