code: def _check_ts_freq(x_df, datetime_freq, ts_freq):
      """Check input frequency (main dataframe) with ts_freq.
  
      check 1- Determine whether input ts_freq is valid or not.
      check 2- Compare the frequency of main dataframe with 'ts_freq'.
  
      Parameters
      ----------
      x_df : DataFrame
          Dataframe with time index
      datetime_freq : str
          Frequency of main dataframe (x_df)
      ts_freq : str
          selected frequency by user, can be one of the following:
          {"H", "D", "W", "M", "Q", "Y"}
  
      Raises
      ------
      ValueError
          Raise an error if:
          1- input ts_freq is invalid and not in the specified dict i.e.,
          {"H", "D", "W", "M", "Q", "Y"}
          2- Level of base dataframe ts_frequency  is lower than selected ts_freq
      """
      # Check 1: Determine whether input ts_freq is valid or not
      freq_list = datetime_freq["frequency"].tolist()
      if (ts_freq is not None) & (ts_freq not in freq_list):
          raise ValueError(
              f"Invalid ts_freq specified, must be in: {freq_list}"
          )
  
      # Check 2: Compare the frequency of main dataframe with 'ts_freq'
      # 2-1: Determine frequency of main DataFrame, find in ranking
      main_df_datetime_freq = pd.infer_freq(x_df["date_sequence"])[0]
      rank_main_df = datetime_freq.loc[
          datetime_freq["frequency"] == main_df_datetime_freq, "rank"
      ].max()
      rank_ts_freq = datetime_freq.loc[
          datetime_freq["frequency"] == ts_freq, "rank"
      ].max()
      # 2-2: Compare the frequency of main df with 'ts_freq'
      if rank_main_df < rank_ts_freq:
          raise ValueError(
              "Level of base dataframe ts_frequency  is lower than selected ts_freq"
          )
  
file_path: sktime/sktime/transformations/series/peak.py
imports: import pandas
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 4 for calling a global function with example usage: _check_ts_freq(x_df, datetime_freq, ts_freq) without return types