code: def _line_for_search(x0, alpha, lower_bound, upper_bound):
      """
      Given a parameter vector ``x0`` with length ``n`` and a direction
      vector ``alpha`` with length ``n``, and lower and upper bounds on
      each of the ``n`` parameters, what are the bounds on a scalar
      ``l`` such that ``lower_bound <= x0 + alpha * l <= upper_bound``.
  
  
      Parameters
      ----------
      x0 : np.array.
          The vector representing the current location.
          Note ``np.shape(x0) == (n,)``.
      alpha : np.array.
          The vector representing the direction.
          Note ``np.shape(alpha) == (n,)``.
      lower_bound : np.array.
          The lower bounds for each parameter in ``x0``. If the ``i``th
          parameter in ``x0`` is unbounded below, then ``lower_bound[i]``
          should be ``-np.inf``.
          Note ``np.shape(lower_bound) == (n,)``.
      upper_bound : np.array.
          The upper bounds for each parameter in ``x0``. If the ``i``th
          parameter in ``x0`` is unbounded above, then ``upper_bound[i]``
          should be ``np.inf``.
          Note ``np.shape(upper_bound) == (n,)``.
  
      Returns
      -------
      res : tuple ``(lmin, lmax)``
          The bounds for ``l`` such that
              ``lower_bound[i] <= x0[i] + alpha[i] * l <= upper_bound[i]``
          for all ``i``.
  
      """
      # get nonzero indices of alpha so we don't get any zero division errors.
      # alpha will not be all zero, since it is called from _linesearch_powell
      # where we have a check for this.
      (nonzero,) = alpha.nonzero()
      lower_bound, upper_bound = (
          lower_bound[nonzero],
          upper_bound[nonzero],
      )
      x0, alpha = x0[nonzero], alpha[nonzero]
      low = (lower_bound - x0) / alpha
      high = (upper_bound - x0) / alpha
  
      # positive and negative indices
      pos = alpha > 0
  
      lmin_pos = np.where(pos, low, 0)
      lmin_neg = np.where(pos, 0, high)
      lmax_pos = np.where(pos, high, 0)
      lmax_neg = np.where(pos, 0, low)
  
      lmin = np.max(lmin_pos + lmin_neg)
      lmax = np.min(lmax_pos + lmax_neg)
  
      # if x0 is outside the bounds, then it is possible that there is
      # no way to get back in the bounds for the parameters being updated
      # with the current direction alpha.
      # when this happens, lmax < lmin.
      # If this is the case, then we can just return (0, 0)
      return (lmin, lmax) if lmax >= lmin else (0, 0)
  
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 31 for calling a global function with example usage: _line_for_search(x0, alpha, lower_bound, upper_bound) and returns: unknown