code: def cohere(
      x,
      y,
      NFFT=256,
      Fs=2,
      detrend=detrend_none,
      window=window_hanning,
      noverlap=0,
      pad_to=None,
      sides="default",
      scale_by_freq=None,
  ):
      r"""
      The coherence between *x* and *y*.  Coherence is the normalized
      cross spectral density:
  
      .. math::
  
          C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}
  
      Parameters
      ----------
      x, y
          Array or sequence containing the data
  
      %(Spectral)s
  
      %(PSD)s
  
      noverlap : int, default: 0 (no overlap)
          The number of points of overlap between segments.
  
      Returns
      -------
      Cxy : 1-D array
          The coherence vector.
      freqs : 1-D array
              The frequencies for the elements in *Cxy*.
  
      See Also
      --------
      :func:`psd`, :func:`csd` :
          For information about the methods used to compute :math:`P_{xy}`,
          :math:`P_{xx}` and :math:`P_{yy}`.
      """
      if len(x) < 2 * NFFT:
          raise ValueError(
              "Coherence is calculated by averaging over *NFFT* length "
              "segments.  Your signal is too short for your choice of *NFFT*."
          )
      Pxx, f = psd(
          x,
          NFFT,
          Fs,
          detrend,
          window,
          noverlap,
          pad_to,
          sides,
          scale_by_freq,
      )
      Pyy, f = psd(
          y,
          NFFT,
          Fs,
          detrend,
          window,
          noverlap,
          pad_to,
          sides,
          scale_by_freq,
      )
      Pxy, f = csd(
          x,
          y,
          NFFT,
          Fs,
          detrend,
          window,
          noverlap,
          pad_to,
          sides,
          scale_by_freq,
      )
      Cxy = np.abs(Pxy) ** 2 / (Pxx * Pyy)
      return Cxy, f
  
imports: import functools
  from numbers import Number
  import numpy
  from matplotlib import _api, _docstring, cbook
label_desc: Use image node_id 12 for calling a global function with example usage: cohere(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides, scale_by_freq) and returns: Cxy,  f