The log variance is necessary to compute the KL divergence term in the loss function.
During training, the VAE minimizes a loss function that includes a reconstruction loss and a KL divergence term. The reconstruction loss measures the error between the input and its reconstruction, while the KL divergence term measures the distance between the encoder's distribution and a prior distribution over the latent space.
See also: Mathematical details from this article.
However, in the github you've mentioned, the standard deviation is a trick to generate images from the model.
It is used in the function generate, which is applied to retrieve images from the model in experiment.py :
def sample_images(self):
# Get sample reconstruction image
test_input, test_label = next(iter(self.trainer.datamodule.test_dataloader()))
test_input = test_input.to(self.curr_device)
test_label = test_label.to(self.curr_device)
# test_input, test_label = batch
recons = self.model.generate(test_input, labels = test_label)
vutils.save_image(recons.data,
os.path.join(self.logger.log_dir ,
"Reconstructions",
f"recons_{self.logger.name}_Epoch_{self.current_epoch}.png"),
normalize=True,
nrow=12)