import tensorflow as tf

        log_y = log_x*scales + mus
        ldj += log_sigmas
        z = tf.math.exp(log_y)
        return z, ldj
    else:
        scales = tf.math.exp(-log_sigmas)
        log_x = tf.math.log(x)
        ldj = -log_x
        log_y = (log_x - mus)*scales
        ldj -= log_sigmas
        z = tf.math.exp(log_y)
        return z, ldj

class LogGaussianize(Parameterize):
    """
    Implementation of Parameterize for a log-Gaussian prior.
    """
    def __init__(self, input_shape=None, epsilon=1.0E-3, name='log_gaussianize', *args, **kwargs):
        super().__init__(*args, num_parameters=2, input_shape=input_shape, name=name, **kwargs)
        self.epsilon = epsilon
