def tf_next_step(self, x, iteration, deltas, improvement, last_improvement, estimated_improvement):
next_step = super(LineSearch, self).tf_next_step(<EOL>x, iteration, deltas, improvement, last_improvement, estimated_improvement<EOL>)<EOL>def undo_deltas():<EOL><INDENT>value = self.fn_x([-delta for delta in deltas])<EOL>with tf.control_dependencies(control_inputs=(value,)):<EOL><INDENT>return tf.less(x=value, y=value)  <EOL><DEDENT><DEDENT>improved = tf.cond(<EOL>pred=(improvement > last_improvement),<EOL>true_fn=(lambda: True),<EOL>false_fn=undo_deltas<EOL>)<EOL>next_step = tf.logical_and(x=next_step, y=improved)<EOL>next_step = tf.logical_and(x=next_step, y=(improvement < self.accept_ratio))<EOL>return tf.logical_and(x=next_step, y=(estimated_improvement > util.epsilon))<EOL>
Termination condition: max number of iterations, or no improvement for last step, or  
improvement less than acceptable ratio, or estimated value not positive.

Args:
    x: Current solution estimate $x_t$.
    iteration: Current iteration counter $t$.
    deltas: Current difference $x_t - x'$.
    improvement: Current improvement $(f(x_t) - f(x')) / v'$.
    last_improvement: Last improvement $(f(x_{t-1}) - f(x')) / v'$.
    estimated_improvement: Current estimated value $v'$.

Returns:
    True if another iteration should be performed.