code: def periodogram(
      x,
      fs=1.0,
      window="boxcar",
      nfft=None,
      detrend="constant",
      return_onesided=True,
      scaling="density",
      axis=-1,
  ):
      """
      Estimate power spectral density using a periodogram.
  
      Parameters
      ----------
      x : array_like
          Time series of measurement values
      fs : float, optional
          Sampling frequency of the `x` time series. Defaults to 1.0.
      window : str or tuple or array_like, optional
          Desired window to use. If `window` is a string or tuple, it is
          passed to `get_window` to generate the window values, which are
          DFT-even by default. See `get_window` for a list of windows and
          required parameters. If `window` is array_like it will be used
          directly as the window and its length must be nperseg. Defaults
          to 'boxcar'.
      nfft : int, optional
          Length of the FFT used. If `None` the length of `x` will be
          used.
      detrend : str or function or `False`, optional
          Specifies how to detrend each segment. If `detrend` is a
          string, it is passed as the `type` argument to the `detrend`
          function. If it is a function, it takes a segment and returns a
          detrended segment. If `detrend` is `False`, no detrending is
          done. Defaults to 'constant'.
      return_onesided : bool, optional
          If `True`, return a one-sided spectrum for real data. If
          `False` return a two-sided spectrum. Defaults to `True`, but for
          complex data, a two-sided spectrum is always returned.
      scaling : { 'density', 'spectrum' }, optional
          Selects between computing the power spectral density ('density')
          where `Pxx` has units of V**2/Hz and computing the power
          spectrum ('spectrum') where `Pxx` has units of V**2, if `x`
          is measured in V and `fs` is measured in Hz. Defaults to
          'density'
      axis : int, optional
          Axis along which the periodogram is computed; the default is
          over the last axis (i.e. ``axis=-1``).
  
      Returns
      -------
      f : ndarray
          Array of sample frequencies.
      Pxx : ndarray
          Power spectral density or power spectrum of `x`.
  
      See Also
      --------
      welch: Estimate power spectral density using Welch's method
      lombscargle: Lomb-Scargle periodogram for unevenly sampled data
      """
      x = cupy.asarray(x)
  
      if x.size == 0:
          return cupy.empty(x.shape), cupy.empty(x.shape)
  
      if window is None:
          window = "boxcar"
  
      if nfft is None:
          nperseg = x.shape[axis]
      elif nfft == x.shape[axis]:
          nperseg = nfft
      elif nfft > x.shape[axis]:
          nperseg = x.shape[axis]
      elif nfft < x.shape[axis]:
          # cupy.s_ not implemented
          s = [cupy.s_[:]] * len(x.shape)
          s[axis] = cupy.s_[:nfft]
          x = cupy.asarray(x[tuple(s)])
          nperseg = nfft
          nfft = None
  
      return welch(
          x,
          fs=fs,
          window=window,
          nperseg=nperseg,
          noverlap=0,
          nfft=nfft,
          detrend=detrend,
          return_onesided=return_onesided,
          scaling=scaling,
          axis=axis,
      )
  
file_path: cupy/cupyx/scipy/signal/_spectral.py
imports: import warnings
  import cupy
  from cupyx.scipy.signal.windows._windows import get_window
  from cupyx.scipy.signal._spectral_impl import _lombscargle, _spectral_helper, _median_bias, _triage_segments
label_desc: Use image node_id 2 for calling a global function with example usage: periodogram(x, fs, window, nfft, detrend, return_onesided, scaling, axis) and returns: welch, cupy,  cupy