where

Stage 1: Train dVAE

VQVAE2 but use gumbel-softmax relaxation instead of straght-through estimator.

Stage 2: Learning the Prior