class_docstr: Conjugate gradient algorithm which iteratively finds a solution $x$ for a system of linear  
  equations of the form $A x = b$, where $A x$ could be, for instance, a locally linear  
  approximation of a high-dimensional function.
  
  See below pseudo-code taken from  
  [Wikipedia](https://en.wikipedia.org/wiki/Conjugate_gradient_method#The_resulting_algorithm):
  
  ```text
  def conjgrad(A, b, x_0):
      r_0 := b - A * x_0
      c_0 := r_0
      r_0^2 := r^T * r
  
      for t in 0, ..., max_iterations - 1:
          Ac := A * c_t
          cAc := c_t^T * Ac
          lpha := r_t^2 / cAc
          x_{t+1} := x_t + lpha * c_t
          r_{t+1} := r_t - lpha * Ac
          r_{t+1}^2 := r_{t+1}^T * r_{t+1}
          if r_{t+1} < \epsilon:
              break
          eta = r_{t+1}^2 / r_t^2
          c_{t+1} := r_{t+1} + eta * c_t
  
      return x_{t+1}
  ```
class_docstr_tok: ["Conjugate","gradient","algorithm","which","iteratively","finds","a","solution","$","x","$","for","a","system","of","linear","equations","of","the","form","$","A","x","=","b","$",",","where","$","A","x","$","could","be",",","for","instance",",","a","locally","linear","approximation","of","a","high-dimensional","function",".","See","below","pseudo-code","taken","from","[","Wikipedia","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Conjugate_gradient_method","#","The_resulting_algorithm",")",":","``","`","text","def","conjgrad","(","A",",","b",",","x_0",")",":","r_0",":","=","b","-","A","*","x_0","c_0",":","=","r_0","r_0^2",":","=","r^T","*","r","for","t","in","0",",","...",",","max_iterations","-","1",":","Ac",":","=","A","*","c_t","cAc",":","=","c_t^T","*","Ac","\u0007lpha",":","=","r_t^2","\/","cAc","x_","{","t+1","}",":","=","x_t","+","\u0007lpha","*","c_t","r_","{","t+1","}",":","=","r_t","-","\u0007lpha","*","Ac","r_","{","t+1","}","^2",":","=","r_","{","t+1","}","^T","*","r_","{","t+1","}","if","r_","{","t+1","}","<","\\epsilon",":","break","\beta","=","r_","{","t+1","}","^2","\/","r_t^2","c_","{","t+1","}",":","=","r_","{","t+1","}","+","\beta","*","c_t","return","x_","{","t+1","}","``","`"]
docstr: Initialization step preparing the arguments for the first iteration of the loop body:
  $x_0, 0, p_0, r_0, r_0^2$.
  
  Args:
      arguments: ???
      x_init: Initial solution guess $x_0$, zero vector if None.
      b: The right-hand side $b$ of the system of linear equations.
  
  Returns:
      Initial arguments for step.
docstr_tok: ["Initialization","step","preparing","the","arguments","for","the","first","iteration","of","the","loop","body",":","$","x_0",",","0",",","p_0",",","r_0",",","r_0^2","$",".","Args",":","arguments",":","?","?","?","x_init",":","Initial","solution","guess","$","x_0","$",",","zero","vector","if","None",".","b",":","The","right-hand","side","$","b","$","of","the","system","of","linear","equations",".","Returns",":","Initial","arguments","for","step","."]
code: def start(self, *, arguments, x_init, b):
      """
      Initialization step preparing the arguments for the first iteration of the loop body:
      $x_0, 0, p_0, r_0, r_0^2$.
  
      Args:
          arguments: ???
          x_init: Initial solution guess $x_0$, zero vector if None.
          b: The right-hand side $b$ of the system of linear equations.
  
      Returns:
          Initial arguments for step.
      """
      # r_0 := b - A * x_0
      # c_0 := r_0
      fx = self.fn_x(arguments, x_init)
      subtract = functools.partial(
          tf_util.lift_indexedslices,
          tf.math.subtract,
          with_assertions=self.config.create_tf_assertions,
      )
      conjugate = residual = b.fmap(function=subtract, zip_values=fx)
  
      # r_0^2 := r^T * r
      multiply = functools.partial(
          tf_util.lift_indexedslices,
          tf.math.multiply,
          with_assertions=self.config.create_tf_assertions,
      )
      squared_residual = tf.math.add_n(
          inputs=[
              tf.math.reduce_sum(input_tensor=multiply(res, res))
              for res in residual.values()
          ]
      )
  
      return arguments, x_init, conjugate, residual, squared_residual
  
file_path: tensorforce/tensorforce/core/optimizers/solvers/conjugate_gradient.py
imports: import functools
  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 5 for calling the ConjugateGradient obj's underlying member method code with example usage: obj.start() and returns: arguments,  x_init,  conjugate,  residual,  squared_residual