code: def vae_loss(expected, predicted):
      mean = tf.get_collection("mu")[-1]
      log_var = tf.get_collection("sigma")[-1]
  
      epsilon = 1e-7
      predicted = tf.clip_by_value(predicted, epsilon, 1.0 - epsilon)
  
      crossentropy_loss = binary_crossentropy(expected, predicted)
      kl_loss = tf.reduce_sum(
          1 + log_var - tf.square(mean) - tf.exp(log_var), axis=1
      )
      return tf.reduce_mean(-crossentropy_loss - 0.5 * kl_loss)
  
file_path: neupy/examples/autoencoder/variational_autoencoder.py
imports: import numpy
  import tensorflow
  import matplotlib.pyplot
  import matplotlib.gridspec
  from sklearn import model_selection, datasets
  from neupy import algorithms
  from neupy.layers import *
  from neupy.exceptions import LayerConnectionError
label_desc: Use image node_id 4 for calling a global function with example usage: vae_loss(expected, predicted) and returns: tf