code: def vae_loss(x_reconstructed, x_true):
      # Reconstruction loss
      encode_decode_loss = x_true * tf.log(1e-10 + x_reconstructed) + (
          1 - x_true
      ) * tf.log(1e-10 + 1 - x_reconstructed)
      encode_decode_loss = -tf.reduce_sum(encode_decode_loss, 1)
      # KL Divergence loss
      kl_div_loss = 1 + z_std - tf.square(z_mean) - tf.exp(z_std)
      kl_div_loss = -0.5 * tf.reduce_sum(kl_div_loss, 1)
      return tf.reduce_mean(encode_decode_loss + kl_div_loss)
  
file_path: tflearn/examples/images/variational_autoencoder.py
imports: from __future__ import division, print_function, absolute_import
  import numpy
  import matplotlib.pyplot
  from scipy.stats import norm
  import tensorflow.compat.v1
  import tflearn
  import tflearn.datasets.mnist
label_desc: Use image node_id 1 for calling a global function with example usage: vae_loss(x_reconstructed, x_true) and returns: tf