code: def check_grad(func, grad, x0, *args, **kwargs):
      """Check the correctness of a gradient function by comparing it against a
      (forward) finite-difference approximation of the gradient.
  
      Parameters
      ----------
      func : callable ``func(x0, *args)``
          Function whose derivative is to be checked.
      grad : callable ``grad(x0, *args)``
          Gradient of `func`.
      x0 : ndarray
          Points to check `grad` against forward difference approximation of grad
          using `func`.
      args : \\*args, optional
          Extra arguments passed to `func` and `grad`.
      epsilon : float, optional
          Step size used for the finite difference approximation. It defaults to
          ``sqrt(np.finfo(float).eps)``, which is approximately 1.49e-08.
  
      Returns
      -------
      err : float
          The square root of the sum of squares (i.e., the 2-norm) of the
          difference between ``grad(x0, *args)`` and the finite difference
          approximation of `grad` using func at the points `x0`.
  
      See Also
      --------
      approx_fprime
  
      Examples
      --------
      >>> def func(x):
      ...     return x[0]**2 - 0.5 * x[1]**3
      >>> def grad(x):
      ...     return [2 * x[0], -1.5 * x[1]**2]
      >>> from scipy.optimize import check_grad
      >>> check_grad(func, grad, [1.5, -1.5])
      2.9802322387695312e-08
  
      """
      step = kwargs.pop("epsilon", _epsilon)
      if kwargs:
          raise ValueError(
              "Unknown keyword arguments: %r" % (list(kwargs.keys()),)
          )
      return sqrt(
          sum(
              (grad(x0, *args) - approx_fprime(x0, func, step, *args))
              ** 2
          )
      )
  
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 15 for calling a global function with example usage: check_grad(func, grad, x0) and returns: sqrt