code: def to_mono(y: np.ndarray) -> np.ndarray:
      """Convert an audio signal to mono by averaging samples across channels.
  
      Parameters
      ----------
      y : np.ndarray [shape=(..., n)]
          audio time series. Multi-channel is supported.
  
      Returns
      -------
      y_mono : np.ndarray [shape=(n,)]
          ``y`` as a monophonic time-series
  
      Notes
      -----
      This function caches at level 20.
  
      Examples
      --------
      >>> y, sr = librosa.load(librosa.ex('trumpet', hq=True), mono=False)
      >>> y.shape
      (2, 117601)
      >>> y_mono = librosa.to_mono(y)
      >>> y_mono.shape
      (117601,)
      """
      # Validate the buffer.  Stereo is ok here.
      util.valid_audio(y, mono=False)
  
      if y.ndim > 1:
          y = np.mean(y, axis=tuple(range(y.ndim - 1)))
  
      return y
  
imports: from __future__ import annotations
  import os
  import pathlib
  import warnings
  import soundfile
  import audioread
  import numpy
  import scipy.signal
  import soxr
  import lazy_loader
  from numba import jit, stencil, guvectorize
  from .fft import get_fftlib
  from .convert import frames_to_samples, time_to_samples
  from .._cache import cache
  from ..None import util
  from ..util.exceptions import ParameterError
  from ..util.decorators import deprecated
  from ..util.deprecation import Deprecated, rename_kw
  from .._typing import _FloatLike_co, _IntLike_co, _SequenceLike
  from typing import Any, BinaryIO, Callable, Generator, Optional, Tuple, Union, List
  from numpy.typing import DTypeLike, ArrayLike
label_desc: Use image node_id 5 for calling a global function with example usage: to_mono(y) and returns: y