code: def _compute_absolute_step(rel_step, x0, f0, method):
      """
      Computes an absolute step from a relative step for finite difference
      calculation.
  
      Parameters
      ----------
      rel_step: None or array-like
          Relative step for the finite difference calculation
      x0 : np.ndarray
          Parameter vector
      f0 : np.ndarray or scalar
      method : {'2-point', '3-point', 'cs'}
  
      Returns
      -------
      h : float
          The absolute step size
  
      Notes
      -----
      `h` will always be np.float64. However, if `x0` or `f0` are
      smaller floating point dtypes (e.g. np.float32), then the absolute
      step size will be calculated from the smallest floating point size.
      """
      # this is used instead of np.sign(x0) because we need
      # sign_x0 to be 1 when x0 == 0.
      sign_x0 = (x0 >= 0).astype(float) * 2 - 1
  
      rstep = _eps_for_method(x0.dtype, f0.dtype, method)
  
      if rel_step is None:
          abs_step = rstep * sign_x0 * np.maximum(1.0, np.abs(x0))
      else:
          # User has requested specific relative steps.
          # Don't multiply by max(1, abs(x0) because if x0 < 1 then their
          # requested step is not used.
          abs_step = rel_step * sign_x0 * np.abs(x0)
  
          # however we don't want an abs_step of 0, which can happen if
          # rel_step is 0, or x0 is 0. Instead, substitute a realistic step
          dx = (x0 + abs_step) - x0
          abs_step = np.where(
              dx == 0,
              rstep * sign_x0 * np.maximum(1.0, np.abs(x0)),
              abs_step,
          )
  
      return abs_step
  
file_path: scipy/scipy/optimize/_numdiff.py
imports: import functools
  import numpy
  from numpy.linalg import norm
  from scipy.sparse.linalg import LinearOperator
  from ..sparse import issparse, csc_matrix, csr_matrix, coo_matrix, find
  from ._group_columns import group_dense, group_sparse
  from scipy._lib._array_api import atleast_nd, array_namespace
label_desc: Use image node_id 3 for calling a global function with example usage: _compute_absolute_step(rel_step, x0, f0, method) and returns: abs_step