'Compute high moment of privacy loss.
Args:
sigma: the noise sigma, in the multiples of the sensitivity.
q: the sampling ratio.
moment_order: the order of moment.
Returns:
log E[exp(moment_order * X)]'

def _compute_log_moment(self, sigma, q, moment_order):

    assert (moment_order <= self._max_moment_order), ('The    order    of    %d    is    out    of    the    upper    bound    %d.' % (moment_order, self._max_moment_order))
    binomial_table = tf.slice(self._binomial_table, [moment_order, 0], [1, (moment_order + 1)])
    qs = tf.exp((tf.constant([(i * 1.0) for i in range((moment_order + 1))], dtype=tf.float64) * tf.cast(tf.log(q), dtype=tf.float64)))
    moments0 = self._differential_moments(sigma, 0.0, moment_order)
    term0 = tf.reduce_sum(((binomial_table * qs) * moments0))
    moments1 = self._differential_moments(sigma, 1.0, moment_order)
    term1 = tf.reduce_sum(((binomial_table * qs) * moments1))
    return tf.squeeze(tf.log(tf.cast(((q * term0) + ((1.0 - q) * term1)), tf.float64)))
