code: def csd(
      x,
      y,
      NFFT=None,
      Fs=None,
      detrend=None,
      window=None,
      noverlap=None,
      pad_to=None,
      sides=None,
      scale_by_freq=None,
  ):
      """
      Compute the cross-spectral density.
  
      The cross spectral density :math:`P_{xy}` by Welch's average
      periodogram method.  The vectors *x* and *y* are divided into
      *NFFT* length segments.  Each segment is detrended by function
      *detrend* and windowed by function *window*.  *noverlap* gives
      the length of the overlap between segments.  The product of
      the direct FFTs of *x* and *y* are averaged over each segment
      to compute :math:`P_{xy}`, with a scaling to correct for power
      loss due to windowing.
  
      If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero
      padded to *NFFT*.
  
      Parameters
      ----------
      x, y : 1-D arrays or sequences
          Arrays or sequences containing the data
  
      %(Spectral)s
  
      %(PSD)s
  
      noverlap : int, default: 0 (no overlap)
          The number of points of overlap between segments.
  
      Returns
      -------
      Pxy : 1-D array
          The values for the cross spectrum :math:`P_{xy}` before scaling (real
          valued)
  
      freqs : 1-D array
          The frequencies corresponding to the elements in *Pxy*
  
      References
      ----------
      Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
      Wiley & Sons (1986)
  
      See Also
      --------
      psd : equivalent to setting ``y = x``.
      """
      if NFFT is None:
          NFFT = 256
      Pxy, freqs, _ = _spectral_helper(
          x=x,
          y=y,
          NFFT=NFFT,
          Fs=Fs,
          detrend_func=detrend,
          window=window,
          noverlap=noverlap,
          pad_to=pad_to,
          sides=sides,
          scale_by_freq=scale_by_freq,
          mode="psd",
      )
  
      if Pxy.ndim == 2:
          if Pxy.shape[1] > 1:
              Pxy = Pxy.mean(axis=1)
          else:
              Pxy = Pxy[:, 0]
      return Pxy, freqs
  
imports: import functools
  from numbers import Number
  import numpy
  from matplotlib import _api, _docstring, cbook
label_desc: Use image node_id 10 for calling a global function with example usage: csd(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides, scale_by_freq) and returns: Pxy,  freqs