class_docstr: Computes Hessian-vector product using finite difference method.
  
  Args:
      base_eps (float): Base epsilon value.
      symmetric (bool): Symmetric or not.
      num_slices (int): Hessian-vector product function's inputs will be
          divided into num_slices and then averaged together to improve
          performance.
class_docstr_tok: ["Computes","Hessian-vector","product","using","finite","difference","method",".","Args",":","base_eps","(","float",")",":","Base","epsilon","value",".","symmetric","(","bool",")",":","Symmetric","or","not",".","num_slices","(","int",")",":","Hessian-vector","product","function","'s","inputs","will","be","divided","into","num_slices","and","then","averaged","together","to","improve","performance","."]
docstr: Build the symbolic graph to compute the Hessian-vector product.
  
  Args:
      f (tf.Tensor): The function whose Hessian needs to be computed.
      target (garage.tf.policies.Policy): A parameterized object to
          optimize over.
      inputs (tuple[tf.Tensor]): The inputs for function f.
      reg_coeff (float): A small value so that A -> A + reg*I.
      name (str): Name to be used in tf.name_scope.
docstr_tok: ["Build","the","symbolic","graph","to","compute","the","Hessian-vector","product",".","Args",":","f","(","tf.Tensor",")",":","The","function","whose","Hessian","needs","to","be","computed",".","target","(","garage.tf.policies.Policy",")",":","A","parameterized","object","to","optimize","over",".","inputs","(","tuple","[","tf.Tensor","]",")",":","The","inputs","for","function","f.","reg_coeff","(","float",")",":","A","small","value","so","that","A","-",">","A","+","reg","*","I.","name","(","str",")",":","Name","to","be","used","in","tf.name_scope","."]
code: def update_hvp(
      self, f, target, inputs, reg_coeff, name="FiniteDifferenceHVP"
  ):
      """Build the symbolic graph to compute the Hessian-vector product.
  
      Args:
          f (tf.Tensor): The function whose Hessian needs to be computed.
          target (garage.tf.policies.Policy): A parameterized object to
              optimize over.
          inputs (tuple[tf.Tensor]): The inputs for function f.
          reg_coeff (float): A small value so that A -> A + reg*I.
          name (str): Name to be used in tf.name_scope.
  
      """
      self._target = target
      self._reg_coeff = reg_coeff
      params = target.get_params()
      with tf.name_scope(name):
          constraint_grads = tf.gradients(
              f, xs=params, name="gradients_constraint"
          )
          for idx, (grad, param) in enumerate(
              zip(constraint_grads, params)
          ):
              if grad is None:
                  constraint_grads[idx] = tf.zeros_like(param)
          flat_grad = flatten_tensor_variables(constraint_grads)
  
          def f_hx_plain(*args):
              """Computes product of Hessian(f) and vector v.
  
              Args:
                  args (tuple[numpy.ndarray]): Contains inputs of function f
                      , and vector v.
  
              Returns:
                  tf.Tensor: Symbolic result.
  
              """
              with tf.name_scope("f_hx_plain"):
                  inputs_ = args[: len(inputs)]
                  xs = args[len(inputs) :]
                  flat_xs = np.concatenate(
                      [np.reshape(x, (-1,)) for x in xs]
                  )
                  param_val = self._target.get_param_values()
                  eps = np.cast["float32"](
                      self.base_eps / (np.linalg.norm(param_val) + 1e-8)
                  )
                  self._target.set_param_values(
                      param_val + eps * flat_xs
                  )
                  flat_grad_dvplus = self._hvp_fun["f_grad"](*inputs_)
                  self._target.set_param_values(param_val)
                  if self.symmetric:
                      self._target.set_param_values(
                          param_val - eps * flat_xs
                      )
                      flat_grad_dvminus = self._hvp_fun["f_grad"](
                          *inputs_
                      )
                      hx = (flat_grad_dvplus - flat_grad_dvminus) / (
                          2 * eps
                      )
                      self._target.set_param_values(param_val)
                  else:
                      flat_grad = self._hvp_fun["f_grad"](*inputs_)
                      hx = (flat_grad_dvplus - flat_grad) / eps
                  return hx
  
          self._hvp_fun = LazyDict(
              f_grad=lambda: compile_function(
                  inputs=inputs,
                  outputs=flat_grad,
              ),
              f_hx_plain=lambda: f_hx_plain,
          )
  
imports: import abc
  from dowel import logger
  import numpy
  import tensorflow
  from garage.tf import compile_function, flatten_tensor_variables, new_tensor_like
  from garage.tf.optimizers._dtypes import LazyDict
label_desc: Use image node_id 2 for calling the FiniteDifferenceHVP obj's underlying member method code with example usage: obj.update_hvp(f, target, inputs, reg_coeff, name) and returns: hx