On line 571 you probably want to have an else statement that sets the reconstruction_loss_gauss = 0.0 if gauss_len is not >0.