code: def sr1(inv_H, delta_w, delta_grad, epsilon=1e-7):
      """
      Symmetric rank 1 (SR1). Generates update for the inverse hessian
      matrix adding symmetric rank-1 matrix. It's possible that there is no
      rank 1 updates for the matrix and in this case update won't be applied
      and original inverse hessian will be returned.
      """
      param = delta_w - dot(inv_H, delta_grad)
      denominator = dot(param, delta_grad)
  
      return tf.where(
          # This check protects from the cases when update
          # doesn't exist. It's possible that during certain
          # iteration there is no rank-1 update for the matrix.
          tf.less(
              tf.abs(denominator),
              epsilon * tf.norm(param) * tf.norm(delta_grad),
          ),
          inv_H,
          inv_H + outer(param, param) / denominator,
      )
  
file_path: neupy/neupy/algorithms/gd/quasi_newton.py
imports: import tensorflow
  from neupy.core.config import Configurable
  from neupy.core.properties import ChoiceProperty, NumberProperty, WithdrawProperty, IntProperty
  from neupy.utils.tf_utils import setup_parameter_updates
  from neupy.algorithms.minsearch.wolfe import line_search
  from neupy.utils import asfloat, dot, outer, as_tuple, function_name_scope, make_single_vector
  from .base import BaseOptimizer
label_desc: Use image node_id 5 for calling a global function with example usage: sr1(inv_H, delta_w, delta_grad, epsilon) and returns: tf