Wouldn’t something like this work:
Assuming L1 = Loss(x, x_hat)
And L2 = Loss(z, z_hat)
1. Compute L2 and backward
2. Zero encoder gradients
3. Compute L1 and backward 
4. Update gradients

Probably a cleaner solution would be using two different optimizers, one just for the decoder (L2) and one for the whole model (L1).