Hi @albanD, thanks for your response!
To be honest I am a bit confused by your answer. Since gradients will not flow back the torch.randn op, how it will propagate back to the inputs x_mean and x_var? Keep in mind that before the sampling step,  x_mean and x_var might be passed through many layers (convolutions, pooling, non-linearities), so what I was thinking is whether gradients will propagate through these layers or not. In any case, I’m just experimenting, so I’ll probably drop this idea at all, but I’m curious whether it could work in PyTorch.