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`.  For an alternative
      way to summarize a precision-recall curve, see
      :func:`average_precision_score`.
  
      Parameters
      ----------
      x : array-like of shape (n,)
          X coordinates. These must be either monotonic increasing or monotonic
          decreasing.
      y : array-like of shape (n,)
          Y coordinates.
  
      Returns
      -------
      auc : float
          Area Under the Curve.
  
      See Also
      --------
      roc_auc_score : Compute the area under the ROC curve.
      average_precision_score : Compute average precision from prediction scores.
      precision_recall_curve : Compute precision-recall pairs for different
          probability thresholds.
  
      Examples
      --------
      >>> import numpy as np
      >>> from sklearn import metrics
      >>> y = np.array([1, 1, 2, 2])
      >>> pred = np.array([0.1, 0.4, 0.35, 0.8])
      >>> fpr, tpr, thresholds = metrics.roc_curve(y, pred, pos_label=2)
      >>> metrics.auc(fpr, tpr)
      0.75
      """
      check_consistent_length(x, y)
      x = column_or_1d(x)
      y = column_or_1d(y)
  
      if x.shape[0] < 2:
          raise ValueError(
              "At least 2 points are needed to compute area under curve, but x.shape = %s"
              % x.shape
          )
  
      direction = 1
      dx = np.diff(x)
      if np.any(dx < 0):
          if np.all(dx <= 0):
              direction = -1
          else:
              raise ValueError(
                  "x is neither increasing nor decreasing : {}.".format(
                      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: import warnings
  from functools import partial
  from numbers import Integral, Real
  import numpy
  from scipy.sparse import csr_matrix, issparse
  from scipy.stats import rankdata
  from ..exceptions import UndefinedMetricWarning
  from ..preprocessing import label_binarize
  from ..utils import assert_all_finite, check_array, check_consistent_length, column_or_1d
  from ..utils._encode import _encode, _unique
  from ..utils._param_validation import Interval, StrOptions, validate_params
  from ..utils.extmath import stable_cumsum
  from ..utils.fixes import trapezoid
  from ..utils.multiclass import type_of_target
  from ..utils.sparsefuncs import count_nonzero
  from ..utils.validation import _check_pos_label_consistency, _check_sample_weight
  from ._base import _average_binary_score, _average_multiclass_ovo_score
label_desc: Use image node_id 1 for calling a global function with example usage: auc(x, y) and returns: area