code: def _minimize_scalar_bounded(
      func,
      bounds,
      args=(),
      xatol=1e-5,
      maxiter=500,
      disp=0,
      **unknown_options,
  ):
      """
      Options
      -------
      maxiter : int
          Maximum number of iterations to perform.
      disp: int, optional
          If non-zero, print messages.
              0 : no message printing.
              1 : non-convergence notification messages only.
              2 : print a message on convergence too.
              3 : print iteration results.
      xatol : float
          Absolute error in solution `xopt` acceptable for convergence.
  
      """
      _check_unknown_options(unknown_options)
      maxfun = maxiter
      # Test bounds are of correct form
      if len(bounds) != 2:
          raise ValueError("bounds must have two elements.")
      x1, x2 = bounds
  
      if not (is_array_scalar(x1) and is_array_scalar(x2)):
          raise ValueError(
              "Optimization bounds must be scalars" " or array scalars."
          )
      if x1 > x2:
          raise ValueError("The lower bound exceeds the upper bound.")
  
      flag = 0
      header = " Func-count     x          f(x)          Procedure"
      step = "       initial"
  
      sqrt_eps = sqrt(2.2e-16)
      golden_mean = 0.5 * (3.0 - sqrt(5.0))
      a, b = x1, x2
      fulc = a + golden_mean * (b - a)
      nfc, xf = fulc, fulc
      rat = e = 0.0
      x = xf
      fx = func(x, *args)
      num = 1
      fmin_data = (1, xf, fx)
      fu = np.inf
  
      ffulc = fnfc = fx
      xm = 0.5 * (a + b)
      tol1 = sqrt_eps * np.abs(xf) + xatol / 3.0
      tol2 = 2.0 * tol1
  
      if disp > 2:
          print(" ")
          print(header)
          print("%5.0f   %12.6g %12.6g %s" % (fmin_data + (step,)))
  
      while np.abs(xf - xm) > (tol2 - 0.5 * (b - a)):
          golden = 1
          # Check for parabolic fit
          if np.abs(e) > tol1:
              golden = 0
              r = (xf - nfc) * (fx - ffulc)
              q = (xf - fulc) * (fx - fnfc)
              p = (xf - fulc) * q - (xf - nfc) * r
              q = 2.0 * (q - r)
              if q > 0.0:
                  p = -p
              q = np.abs(q)
              r = e
              e = rat
  
              # Check for acceptability of parabola
              if (
                  (np.abs(p) < np.abs(0.5 * q * r))
                  and (p > q * (a - xf))
                  and (p < q * (b - xf))
              ):
                  rat = (p + 0.0) / q
                  x = xf + rat
                  step = "       parabolic"
  
                  if ((x - a) < tol2) or ((b - x) < tol2):
                      si = np.sign(xm - xf) + ((xm - xf) == 0)
                      rat = tol1 * si
              else:  # do a golden-section step
                  golden = 1
  
          if golden:  # do a golden-section step
              if xf >= xm:
                  e = a - xf
              else:
                  e = b - xf
              rat = golden_mean * e
              step = "       golden"
  
          si = np.sign(rat) + (rat == 0)
          x = xf + si * np.maximum(np.abs(rat), tol1)
          fu = func(x, *args)
          num += 1
          fmin_data = (num, x, fu)
          if disp > 2:
              print("%5.0f   %12.6g %12.6g %s" % (fmin_data + (step,)))
  
          if fu <= fx:
              if x >= xf:
                  a = xf
              else:
                  b = xf
              fulc, ffulc = nfc, fnfc
              nfc, fnfc = xf, fx
              xf, fx = x, fu
          else:
              if x < xf:
                  a = x
              else:
                  b = x
              if (fu <= fnfc) or (nfc == xf):
                  fulc, ffulc = nfc, fnfc
                  nfc, fnfc = x, fu
              elif (fu <= ffulc) or (fulc == xf) or (fulc == nfc):
                  fulc, ffulc = x, fu
  
          xm = 0.5 * (a + b)
          tol1 = sqrt_eps * np.abs(xf) + xatol / 3.0
          tol2 = 2.0 * tol1
  
          if num >= maxfun:
              flag = 1
              break
  
      if np.isnan(xf) or np.isnan(fx) or np.isnan(fu):
          flag = 2
  
      fval = fx
      if disp > 0:
          _endprint(x, flag, fval, maxfun, xatol, disp)
  
      result = OptimizeResult(
          fun=fval,
          status=flag,
          success=(flag == 0),
          message={
              0: "Solution found.",
              1: "Maximum number of function calls " "reached.",
              2: _status_message["nan"],
          }.get(flag, ""),
          x=xf,
          nfev=num,
      )
  
      return result
  
imports: import warnings
  import sys
  from numpy import atleast_1d, eye, argmin, zeros, shape, squeeze, asarray, sqrt, Inf, asfarray, isinf
  import numpy
  from .linesearch import line_search_wolfe1, line_search_wolfe2, line_search_wolfe2, LineSearchWarning
  from ._numdiff import approx_derivative
  from scipy._lib._util import getfullargspec_no_self
  from scipy._lib._util import MapWrapper
  from scipy.optimize._differentiable_functions import ScalarFunction, FD_METHODS
label_desc: Use image node_id 25 for calling a global function with example usage: _minimize_scalar_bounded(func, bounds, args, xatol, maxiter, disp) and returns: result