code: def get_anomaly_df_from_outliers(
      df,
      time_col,
      value_col,
      freq,
      z_score_cutoff=Z_SCORE_CUTOFF,
      trim_percent=1.0,
  ):
      """This function identifies extreme values as outliers based on z-scores.
      A normal distribution will be fit on ``value_col`` of input df,
      and the time points with corresponding values that satisfy abs(z-scores) >
      ``Z_SCORE_CUTOFF`` will be considered as outliers.
      The function will then construct ``anomaly_df`` based on identified outliers.
      If trimming is specified via ``trim_percent`` to be non-zero,
      data is trimmed in symmetric fashion (removes high and low values) before
      calculating mean and variance of the standard normal.
      This is done to deal with large outliers.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          The dataframe with ``time_col`` and ``value_col``.
      time_col : `str`
          The column name of timestamps in ``df``.
      value_col : `str`
          The column name of values in ``df`` on which z-scores will be calculated to identify outliers.
      freq : `str`
          Pandas timeseries frequency string, e.g. "H", "D", etc.
          See https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases.
      z_score_cutoff : `float`, default ``Z_SCORE_CUTOFF``
          Z score cutoff for outlier detection.
      trim_percent : `float`, default 1.0
          Trimming percent for calculating the variance.
          The function first removes this amount of data in symmetric fashion from
          both ends and then it calculates the mean and the variance.
  
      Returns
      -------
      anomaly_df : `pandas.DataFrame`
          The dataframe that contains anomaly info based on identified outliers.
          It should have
  
              - the anomaly start column "start_time"
                  `~greykite.common.constants.START_TIME_COL`.
              - the anomaly end column "end_time"
                  `~greykite.common.constants.END_TIME_COL.
  
          Both are inclusive.
      """
      if df.empty:
          return None
  
      if time_col not in df.columns:
          raise ValueError(
              f"`df` does not have `time_col` with name {time_col}."
          )
  
      if value_col not in df.columns:
          raise ValueError(
              f"`df` does not have `value_col` with name {value_col}."
          )
  
      df[time_col] = pd.to_datetime(df[time_col])
  
      # Calculates z-scores after trimming (if trimming is not 0)
      # and identifies points with abs(z-score) > `Z_SCORE_CUTOFF` as outliers.
      detect_outlier = ZScoreOutlierDetector(
          diff_method=None,
          trim_percent=trim_percent,
          z_score_cutoff=z_score_cutoff,
      )
  
      detect_outlier.fit(df[value_col])
      fitted = detect_outlier.fitted
      cond_outlier = fitted.is_outlier
  
      # Extracts time points when outliers occur.
      outlier_points = df.loc[cond_outlier, time_col].reset_index(
          drop=True
      )
  
      anomaly_df = pd.DataFrame(columns=[START_TIME_COL, END_TIME_COL])
      if len(outlier_points) > 0:
          anomaly_df[START_TIME_COL] = outlier_points
          anomaly_df[END_TIME_COL] = anomaly_df[START_TIME_COL]
          anomaly_df = get_canonical_anomaly_df(
              anomaly_df=anomaly_df, freq=freq
          )
      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 10 for calling a global function with example usage: get_anomaly_df_from_outliers(df, time_col, value_col, freq, z_score_cutoff, trim_percent) and returns: anomaly_df, None