'Estimate of gradient Variance.
Returns:
C_t ops.'

def _grad_variance(self):

    grad_var_ops = []
    tensor_to_avg = []
    for (t, g) in zip(self._vars, self._grad):
        if isinstance(g, tf.IndexedSlices):
            tensor_to_avg.append(tf.reshape(tf.unsorted_segment_sum(g.values, g.indices, g.dense_shape[0]), shape=t.get_shape()))
        else:
            tensor_to_avg.append(g)
    avg_op = self._moving_averager.apply(tensor_to_avg)
    grad_var_ops.append(avg_op)
    with tf.control_dependencies([avg_op]):
        self._grad_avg = [self._moving_averager.average(val) for val in tensor_to_avg]
        self._grad_avg_squared = [tf.square(val) for val in self._grad_avg]
        self._grad_avg_squared = tf.add_n([tf.reduce_sum(val) for val in self._grad_avg_squared])
    self._grad_var = (self._grad_norm_squared_avg - self._grad_avg_squared)
    return grad_var_ops
