import tensorflow as tf

    means, that the corresponding input to this method should be a `Tensor` with
    each element corresponding to a single output of an encoding. So this can be
    a single element, in the one-to-many setting, or multiple elements, in the
    many-to-one setting.

    The `update_state` method thus can compute arbitrary function of the
    relevant values. In this case, it maintains a rolling average of previous
    states, where the weight to be used depends on the number of updates
    received. Note that the specific implementation is not necessarily useful or
    efficient; it rather serves as an illustration of what can be done.
    """
    num_updates = state_update_tensors[
        self.NORM_STATE_UPDATE_KEY].shape.num_elements()
    norm_mean = tf.reduce_mean(state_update_tensors[self.NORM_STATE_UPDATE_KEY])
    weight = 0.9**num_updates  # Use a stronger weight for more updates.
    new_factor = (
        weight * state[self.FACTOR_STATE_KEY] + (1 - weight) / norm_mean)
    return {self.FACTOR_STATE_KEY: new_factor}

  def get_params(self, state):
    """See base class."""
    params = {self.FACTOR_PARAM_KEY: state[self.FACTOR_STATE_KEY]}
    return params, params

  def encode(self, x, encode_params):
    """See base class."""
