code: def get_anomaly_df(df, time_col=TIME_COL, anomaly_col=ANOMALY_COL):
      """Computes anomaly dataframe from a labeled ``df``.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          A data frame which includes minimally
              - the timestamp column (``time_col``)
              - the anomaly column (``anomaly_col``).
      time_col : `str` or None
          The column name of timestamps in ``df``.
          If None, it is set to
          `~greykite.common.constants.TIME_COL`.
      anomaly_col : `str` or None
          The column name of anomaly labels in ``df``.
          ``True`` indicates anomalous data.
          ``False`` indicates non-anomalous data.
          If None, it is set to
          `~greykite.detection.detector.constants.ANOMALY_COL`.
  
      Returns
      -------
      anomaly_df : `pandas.DataFrame`
          The dataframe that contains anomaly info.
          It should have
              - the anomaly start column "start_time"
              `~greykite.detection.detector.constants.ANOMALY_START_TIME`.
              - the anomaly end column "end_time"
              `~greykite.detection.detector.constants.ANOMALY_END_TIME`.
          Both should be inclusive.
      """
      # Copies `df` by resetting the index to avoid alteration to input df
      df = df.reset_index(drop=True)
      # When all rows are True/ anomalies
      if df[anomaly_col].all():
          start_index = [0]
          end_index = [df.index[-1]]
      # When all rows are False/ not anomalies
      elif not df[anomaly_col].any():
          start_index = []
          end_index = []
      else:
          df[anomaly_col] = df[anomaly_col].astype(int)
          df[f"{anomaly_col}_diff"] = df[anomaly_col].diff()
  
          start_index = df.index[
              df[f"{anomaly_col}_diff"] == 1.0
          ].tolist()
          end_index = df.index[
              df[f"{anomaly_col}_diff"] == -1.0
          ].tolist()
          end_index = [
              index - 1 for index in end_index
          ]  # to make end points inclusive
  
          # The first entry of df is an anomaly
          if df.iloc[0][anomaly_col]:
              start_index.insert(0, 0)
  
          # The last entry of df is an anomaly
          if df.iloc[df.index[-1]][anomaly_col]:
              end_index.append(df.index[-1])
  
      anomaly_df = pd.DataFrame(
          {
              START_TIME_COL: df.iloc[start_index][time_col].values,
              END_TIME_COL: df.iloc[end_index][time_col].values,
          }
      )
  
      return anomaly_df
  
file_path: greykite/greykite/detection/detector/ad_utils.py
imports: from functools import reduce
  import pandas
  from greykite.common.constants import ANOMALY_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.features.outlier import ZScoreOutlierDetector
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.detection.detector.constants import Z_SCORE_CUTOFF
label_desc: Use image node_id 4 for calling a global function with example usage: get_anomaly_df(df, time_col, anomaly_col) and returns: anomaly_df