class_docstr: Performs constrained optimization via backtracking line search.
  
  The search direction is computed using a conjugate gradient algorithm,
  which gives x = A^{-1}g, where A is a second order approximation of the
  constraint and g is the gradient of the loss function.
  
  Args:
      params (iterable): Iterable of parameters to optimize.
      max_constraint_value (float): Maximum constraint value.
      cg_iters (int): The number of CG iterations used to calculate A^-1 g
      max_backtracks (int): Max number of iterations for backtrack
          linesearch.
      backtrack_ratio (float): backtrack ratio for backtracking line search.
      hvp_reg_coeff (float): A small value so that A -> A + reg*I. It is
          used by Hessian Vector Product calculation.
      accept_violation (bool): whether to accept the descent step if it
          violates the line search condition after exhausting all
          backtracking budgets.
class_docstr_tok: ["Performs","constrained","optimization","via","backtracking","line","search",".","The","search","direction","is","computed","using","a","conjugate","gradient","algorithm",",","which","gives","x","=","A^","{","-1","}","g",",","where","A","is","a","second","order","approximation","of","the","constraint","and","g","is","the","gradient","of","the","loss","function",".","Args",":","params","(","iterable",")",":","Iterable","of","parameters","to","optimize",".","max_constraint_value","(","float",")",":","Maximum","constraint","value",".","cg_iters","(","int",")",":","The","number","of","CG","iterations","used","to","calculate","A^-1","g","max_backtracks","(","int",")",":","Max","number","of","iterations","for","backtrack","linesearch",".","backtrack_ratio","(","float",")",":","backtrack","ratio","for","backtracking","line","search",".","hvp_reg_coeff","(","float",")",":","A","small","value","so","that","A","-",">","A","+","reg","*","I",".","It","is","used","by","Hessian","Vector","Product","calculation",".","accept_violation","(","bool",")",":","whether","to","accept","the","descent","step","if","it","violates","the","line","search","condition","after","exhausting","all","backtracking","budgets","."]
docstr: Restore the optimizer state.
  
  Args:
      state (dict): State dictionary.
docstr_tok: ["Restore","the","optimizer","state",".","Args",":","state","(","dict",")",":","State","dictionary","."]
code: def __setstate__(self, state):
      """Restore the optimizer state.
  
      Args:
          state (dict): State dictionary.
  
      """
      if "hvp_reg_coeff" not in state["state"]:
          warnings.warn(
              "Resuming ConjugateGradientOptimizer with lost state. "
              "This behavior is fixed if pickling from garage>=2020.02.0."
          )
      self.defaults = state["defaults"]
      # Set the fields manually so that the setter gets called.
      self.state = state["state"]
      self.param_groups = state["param_groups"]
  
file_path: garage/src/garage/torch/optimizers/conjugate_gradient_optimizer.py
imports: import warnings
  from dowel import logger
  import numpy
  import torch
  from torch.optim import Optimizer
  from garage.np import unflatten_tensors
label_desc: Use image node_id 5 for calling the ConjugateGradientOptimizer obj's underlying member method code with example usage: obj.__setstate__(state) without return types