'Accumulate the privacy spending.
Currently only support approximate privacy. Here we assume we use Gaussian
noise on randomly sampled batch so we get better composition: 1. the per
batch privacy is computed using privacy amplication via sampling bound;
2. the composition is done using the composition with Gaussian noise.
TODO(liqzhang) Add a link to a document that describes the bounds used.
Args:
eps_delta: EpsDelta pair which can be tensors.
unused_sigma: the noise sigma. Unused for this accountant.
num_examples: the number of examples involved.
Returns:
a TensorFlow operation for updating the privacy spending.'

def accumulate_privacy_spending(self, eps_delta, unused_sigma, num_examples):

    (eps, delta) = eps_delta
    with tf.control_dependencies([tf.Assert(tf.greater(delta, 0), ['delta    needs    to    be    greater    than    0'])]):
        amortize_ratio = ((tf.cast(num_examples, tf.float32) * 1.0) / self._total_examples)
        amortize_eps = tf.reshape(tf.log((1.0 + (amortize_ratio * (tf.exp(eps) - 1.0)))), [1])
        amortize_delta = tf.reshape((amortize_ratio * delta), [1])
        return tf.group(*[tf.assign_add(self._eps_squared_sum, tf.square(amortize_eps)), tf.assign_add(self._delta_sum, amortize_delta)])
