code: def _approx_fprime_cs_scalar(x, f, epsilon=None, args=(), kwargs={}):
      """
      Calculate gradient for scalar parameter with complex step derivatives.
  
      This assumes that the function ``f`` is vectorized for a scalar parameter.
      The function value ``f(x)`` has then the same shape as the input ``x``.
      The derivative returned by this function also has the same shape as ``x``.
  
      Parameters
      ----------
      x : ndarray
          Parameters at which the derivative is evaluated.
      f : function
          `f(*((x,)+args), **kwargs)` returning either one value or 1d array.
      epsilon : float, optional
          Stepsize, if None, optimal stepsize is used. Optimal step-size is
          EPS*x. See note.
      args : tuple
          Tuple of additional arguments for function `f`.
      kwargs : dict
          Dictionary of additional keyword arguments for function `f`.
  
      Returns
      -------
      partials : ndarray
         Array of derivatives, gradient evaluated for parameters ``x``.
  
      Notes
      -----
      The complex-step derivative has truncation error O(epsilon**2), so
      truncation error can be eliminated by choosing epsilon to be very small.
      The complex-step derivative avoids the problem of round-off error with
      small epsilon because there is no subtraction.
      """
      # From Guilherme P. de Freitas, numpy mailing list
      # May 04 2010 thread "Improvement of performance"
      # http://mail.scipy.org/pipermail/numpy-discussion/2010-May/050250.html
      x = np.asarray(x)
      n = x.shape[-1]
  
      epsilon = _get_epsilon(x, 1, epsilon, n)
      eps = 1j * epsilon
      partials = f(x + eps, *args, **kwargs).imag / epsilon
  
      return np.array(partials)
  
file_path: statsmodels/statsmodels/tools/numdiff.py
imports: import numpy
  from statsmodels.compat.pandas import Appender, Substitution
label_desc: Use image node_id 5 for calling a global function with example usage: _approx_fprime_cs_scalar(x, f, epsilon, args, kwargs) and returns: np