code: def _auc(x, y):
      """Compute Area Under the Curve (AUC) using the trapezoidal rule
  
      This is a general function, given points on a curve.  For computing the
      area under the ROC-curve, see :func:`roc_auc_score`.
  
      Parameters
      ----------
      x : array, shape = [n]
          x coordinates. These must be either monotonic increasing or monotonic
          decreasing.
      y : array, shape = [n]
          y coordinates.
  
      Returns
      -------
      auc : float
      """
      x = np.ravel(x)
      y = np.ravel(y)
  
      direction = 1
      dx = np.diff(x)
      if np.any(dx < 0):
          if np.all(dx <= 0):
              direction = -1
          else:
              raise ValueError(Errors.E164.format(x=x))
  
      area = direction * trapezoid(y, x)
      if isinstance(area, np.memmap):
          # Reductions such as .sum used internally in trapezoid do not return a
          # scalar by default for numpy.memmap instances contrary to
          # regular numpy.ndarray instances.
          area = area.dtype.type(area)
      return area
  
imports: from collections import defaultdict
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple
  import numpy
  from .errors import Errors
  from .morphology import Morphology
  from .tokens import Doc, Span, Token
  from .training import Example
  from .util import SimpleFrozenList, get_lang_class
label_desc: Use image node_id 7 for calling a global function with example usage: _auc(x, y) and returns: area