import tensorflow as tf

        jitter = tfhacks.eye(tf.shape(mu)[0], var.dtype) * 1e-06
        L = tf.batch_cholesky(tf.transpose(var, (2, 0, 1)) + jitter)
        V_shape = [tf.shape(L)[0], tf.shape(L)[1], num_samples]
        V = tf.random_normal(V_shape, dtype=L.dtype)
        samples = tf.expand_dims(tf.transpose(mu), -1) + tf.batch_matmul(L, V)
        return tf.transpose(samples)
        #samples = []
        #for i in range(self.num_latent_functions):
