code: def _linesearch_brent(func, p, xi, tol=1e-3):
      """Line-search algorithm using Brent's method.
  
      Find the minimum of the function ``func(x0+ alpha*direc)``.
      """
  
      def myfunc(alpha):
          return func(p + alpha * xi)
  
      alpha_min, fret, iter, num = brent(myfunc, full_output=1, tol=tol)
      xi = alpha_min * xi
      return np.squeeze(fret), p + xi
  
imports: import numpy
  from scipy.optimize import approx_fprime, brent
label_desc: Use image node_id 1 for calling a global function with example usage: _linesearch_brent(func, p, xi, tol) and returns: np,  unknown, func