code: def ps(x, sign=1, n=None, pad="mean"):
      """Power spectrum transformer.
  
      Power spectrum transform, currently calculated using np function.
      It would be worth looking at ff implementation, see difference in speed
      to java.
  
      Parameters
      ----------
      x : array-like shape = [interval_width]
      sign : {-1, 1}, default = 1
      n : int, default=None
      pad : str or function, default='mean'
          controls the mode of the pad function
          see numpy.pad for more details
          https://numpy.org/doc/stable/reference/generated/numpy.pad.html
  
      Returns
      -------
      y : array-like shape = [len(x)/2]
      """
      from sktime.classification.interval_based._rise_numba import (
          _round_to_nearest_power_of_two,
      )
  
      x_len = x.shape[-1]
      x_is_1d = x.ndim == 1
      # pad or slice series if length is not of power of 2 or n is specified
      if x_len & (x_len - 1) != 0 or n:
          # round n (or the length of x) to next power of 2
          # when n is not specified
          if not n:
              n = _round_to_nearest_power_of_two(x_len)
          # pad series up to n when n is larger otherwise slice series up to n
          if n > x_len:
              pad_length = (
                  (0, n - x_len)
                  if x_is_1d
                  else ((0, 0), (0, n - x_len))
              )
              x_in_power_2 = np.pad(x, pad_length, mode=pad)
          else:
              x_in_power_2 = x[:n] if x_is_1d else x[:, :n]
      else:
          x_in_power_2 = x
      # use sign to determine inverse or normal fft
      # using the norm in numpy fft function
      # backward = normal fft, forward = inverse fft (divide by n after fft)
      # note: use the following code when upgrade numpy to 1.20
      # norm = "backward" if sign > 0 else "forward"
      # fft = np.fft.rfft(x_in_power_2, norm=norm)
      if sign < 0:
          x_in_power_2 /= n
      fft = np.fft.rfft(x_in_power_2)
      fft = fft[:-1] if x_is_1d else fft[:, :-1]
      return np.abs(fft)
  
imports: import numpy
  from joblib import Parallel, delayed
  from sklearn.base import clone
  from sklearn.ensemble._base import _partition_estimators
  from sklearn.tree import DecisionTreeClassifier
  from sklearn.utils.validation import check_random_state
  from sktime.classification.base import BaseClassifier
label_desc: Use image node_id 7 for calling a global function with example usage: ps(x, sign, n, pad) and returns: np