class_docstr: Line search algorithm which iteratively optimizes the value $f(x)$ for $x$ on the line between
  $x'$ and $x_0$ by optimistically taking the first acceptable $x$ starting from $x_0$ and
  moving towards $x'$.
class_docstr_tok: ["Line","search","algorithm","which","iteratively","optimizes","the","value","$","f","(","x",")","$","for","$","x","$","on","the","line","between","$","x","'","$","and","$","x_0","$","by","optimistically","taking","the","first","acceptable","$","x","$","starting","from","$","x_0","$","and","moving","towards","$","x","'","$","."]
docstr: Termination step preparing the return value.
  
  Args:
      x: Final solution estimate $x_n$.
      deltas: Current difference $x_n - x_{n-1}$.
      improvement: Current improvement $(f(x') - f(x_t))$.
      last_improvement: Last improvement $(f(x') - f(x_{t-1}))$.
      base_value: Value $f(x')$ at $x = x'$.
  
  Returns:
      Final solution.
docstr_tok: ["Termination","step","preparing","the","return","value",".","Args",":","x",":","Final","solution","estimate","$","x_n","$",".","deltas",":","Current","difference","$","x_n","-","x_","{","n-1","}","$",".","improvement",":","Current","improvement","$","(","f","(","x","'",")","-","f","(","x_t",")",")","$",".","last_improvement",":","Last","improvement","$","(","f","(","x","'",")","-","f","(","x_","{","t-1","}",")",")","$",".","base_value",":","Value","$","f","(","x","'",")","$","at","$","x","=","x","'","$",".","Returns",":","Final","solution","."]
code: def end(
      self,
      *,
      arguments,
      x,
      deltas,
      improvement,
      last_improvement,
      base_value,
  ):
      """
      Termination step preparing the return value.
  
      Args:
          x: Final solution estimate $x_n$.
          deltas: Current difference $x_n - x_{n-1}$.
          improvement: Current improvement $(f(x') - f(x_t))$.
          last_improvement: Last improvement $(f(x') - f(x_{t-1}))$.
          base_value: Value $f(x')$ at $x = x'$.
  
      Returns:
          Final solution.
      """
  
      def keep_last_step():
          return x.fmap(
              function=(lambda t, delta: t + delta), zip_values=deltas
          )
  
      def undo_last_step():
          target_value = self.fn_x(
              arguments, deltas.fmap(function=(lambda delta: -delta))
          )
  
          dependencies = [target_value]
          if self.config.create_debug_assertions:
              epsilon = tf_util.constant(value=1e-5, dtype="float")
              epsilon = tf.math.maximum(
                  x=epsilon, y=(epsilon * tf.math.abs(x=base_value))
              )
              dependencies.append(
                  tf.debugging.assert_less(
                      x=tf.math.abs(
                          x=(
                              base_value
                              - target_value
                              - last_improvement
                          )
                      ),
                      y=epsilon,
                  )
              )
  
          with tf.control_dependencies(control_inputs=dependencies):
              return x.fmap(function=tf_util.identity)
  
      accept_solution = improvement >= last_improvement
      return tf.cond(
          pred=accept_solution,
          true_fn=keep_last_step,
          false_fn=undo_last_step,
      )
  
file_path: tensorforce/tensorforce/core/optimizers/solvers/line_search.py
imports: import tensorflow
  from tensorforce import util
  from tensorforce.core import parameter_modules, SignatureDict, TensorSpec, tf_function, tf_util
  from tensorforce.core.optimizers.solvers import Iterative
label_desc: Use image node_id 8 for calling the LineSearch obj's underlying member method code with example usage: obj.end() and returns: tf, x, x