However, the vector quantisation operation requires vector extraction by indexing, which is not differentiable. Thus, the gradient from reconstruction loss would not pass through this step, and the encoder would not be trained. To prevent this, as suggested by Van Den Oord et al. for vector quantised variational autoencoder (VQVAE), two losses are usedcodebook and commitment losses. The idea of codebook loss is to shift selected codebook variables closer to the atom vectors while the gradient from the commitment loss moves the atom vectors towards the closest codebook vectors. Later, the authors replaced codebook loss with Exponential Moving Averages (EMA).