code: def autocorrelate(
      y: np.ndarray, *, max_size: Optional[int] = None, axis: int = -1
  ) -> np.ndarray:
      """Bounded-lag auto-correlation
  
      Parameters
      ----------
      y : np.ndarray
          array to autocorrelate
      max_size : int > 0 or None
          maximum correlation lag.
          If unspecified, defaults to ``y.shape[axis]`` (unbounded)
      axis : int
          The axis along which to autocorrelate.
          By default, the last axis (-1) is taken.
  
      Returns
      -------
      z : np.ndarray
          truncated autocorrelation ``y*y`` along the specified axis.
          If ``max_size`` is specified, then ``z.shape[axis]`` is bounded
          to ``max_size``.
  
      Notes
      -----
      This function caches at level 20.
  
      Examples
      --------
      Compute full autocorrelation of ``y``
  
      >>> y, sr = librosa.load(librosa.ex('trumpet'))
      >>> librosa.autocorrelate(y)
      array([ 6.899e+02,  6.236e+02, ...,  3.710e-08, -1.796e-08])
  
      Compute onset strength auto-correlation up to 4 seconds
  
      >>> import matplotlib.pyplot as plt
      >>> odf = librosa.onset.onset_strength(y=y, sr=sr, hop_length=512)
      >>> ac = librosa.autocorrelate(odf, max_size=4 * sr // 512)
      >>> fig, ax = plt.subplots()
      >>> ax.plot(ac)
      >>> ax.set(title='Auto-correlation', xlabel='Lag (frames)')
      """
      if max_size is None:
          max_size = y.shape[axis]
  
      max_size = int(min(max_size, y.shape[axis]))
  
      fft = get_fftlib()
  
      # Pad out the signal to support full-length auto-correlation.
      n_pad = 2 * y.shape[axis] - 1
  
      if np.iscomplexobj(y):
          # Compute the power spectrum along the chosen axis
          powspec = util.abs2(fft.fft(y, n=n_pad, axis=axis))
  
          # Convert back to time domain
          autocorr = fft.ifft(powspec, n=n_pad, axis=axis)
      else:
          # Compute the power spectrum along the chosen axis
          # Pad out the signal to support full-length auto-correlation.
          powspec = util.abs2(fft.rfft(y, n=n_pad, axis=axis))
  
          # Convert back to time domain
          autocorr = fft.irfft(powspec, n=n_pad, axis=axis)
  
      # Slice down to max_size
      subslice = [slice(None)] * autocorr.ndim
      subslice[axis] = slice(max_size)
  
      autocorr_slice: np.ndarray = autocorr[tuple(subslice)]
  
      return autocorr_slice
  
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 9 for calling a global function with example usage: autocorrelate(y) and returns: autocorr_slice