code: def plot_overlay_anomalies_multi_metric(
      df,
      time_col,
      value_cols,
      anomaly_df,
      anomaly_df_grouping_col=None,
      start_time_col=START_TIME_COL,
      end_time_col=END_TIME_COL,
      annotation_text_col=None,
      annotation_position="top left",
      lines_opacity=0.6,
      markers_opacity=0.8,
      vrect_opacity=0.3,
  ):
      """This function operates on a given data frame (``df``) which includes time (given in ``time_col``) and
      metrics (given in ``value_cols``), as well as ``anomaly_df`` which includes the anomaly periods
      corresponding to those metrics. It generates a plot of the metrics annotated with anomaly
      values as markers on the curves and vertical rectangles for the same periods.
      Each metric, its anomaly values and vertical rectangles use the same color with
      varying opacity.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          A data frame which at least inludes a timestamp column (``TIME_COL``) and
          ``value_cols`` which represent the metrics.
      time_col : `str`
          The column name in ``df`` representing time for the time series data.
          The time column can be anything that can be parsed by `pandas.DatetimeIndex`.
      value_cols : `list` [`str`]
          The columns which include the metrics.
      anomaly_df : `pandas.DataFrame`
          Data frame with ``start_time_col`` and ``end_time_col`` and ``grouping_col``
          (if provided). This contains the anomaly periods for each metric
          (one of the ``value_cols``). Each row of this dataframe corresponds
          to an anomaly occurring between the times given in ``row[start_time_col]``
          and ``row[end_time_col]``.
          The ``grouping_col`` (if not None) determines which metric that
          anomaly corresponds too (otherwise we assume all anomalies apply to all metrics).
      anomaly_df_grouping_col : `str` or None, default None
          The column name for grouping the list of the anomalies which is to appear
          in ``anomaly_df``.
          This column should include some of the metric names
          specified in ``value_cols``. The ``grouping_col`` (if not None) determines which metric that
          anomaly corresponds too (otherwise we assume all anomalies apply to all metrics).
      start_time_col : `str`, default ``START_TIME_COL``
          The column name in ``anomaly_df`` representing the start timestamp of
          the anomalous period, inclusive.
          The format can be anything that can be parsed by pandas DatetimeIndex.
      end_time_col : `str`, default ``END_TIME_COL``
          The column name in ``anomaly_df`` representing the start timestamp of
          the anomalous period, inclusive.
          The format can be anything that can be parsed by pandas DatetimeIndex.
      annotation_text_col : `str` or None, default None
          A column which includes annotation texts for each vertical rectangle.
      annotation_position : `str`, default "top left"
          The position of annotation texts with respect to the vertical rectangle.
      lines_opacity : `float`, default 0.6
          The opacity of the colors used in the lines (curves) which represent the
          metrics given in ``value_cols``.
      markers_opacity: `float`, default 0.8
          The opacity of the colors used in the markersc which represent the
          value of the metrics given in ``value_cols`` during anomaly times as
          specified in ``anomaly_df``.
      vrect_opacity : `float`, default 0.3
          The opacity of the colors for the vertical rectangles.
  
  
      Returns
      -------
      result : `dict`
          A dictionary with following items:
  
          - "fig": `plotly.graph_objects.Figure`
              Plotly object which includes the metrics augmented with vertical
              rectangles and annotations.
          - "augmented_df": `pandas.DataFrame`
              This is a dataframe obtained by augmenting the input ``df`` with new
              columns determining if the metrics appearing in ``df`` are anomaly
              or not and the new columns denoting anomaly values and normal values
              (described below).
          - "is_anomaly_cols": `list` [`str`]
              The list of add boolean columns to determine if a value is an anomaly for
              a given metric. The format of the columns is ``f"{metric}_is_anomaly"``.
          - "anomaly_value_cols": `list` [`str`]
              The list of columns containing only anomaly values (`np.nan` otherwise) for each corresponding
              metric. The format of the columns is ``f"{metric}_anomaly_value"``.
          - "normal_value_cols": `list` [`str`]
              The list of columns containing only non-anomalous / normal values (`np.nan` otherwise)
              for each corresponding metric. The format of the columns is ``f"{metric}_normal_value"``.
          - "line_colors": `list` [`str`]
              The colors generated for the metric lines (curves).
          - "marker_colors": `list` [`str`]
              The colors generated for the anomaly values markers.
          - "vrect_colors": `list` [`str`]
              The colors generated for the vertical rectangles.
  
      """
      # Adds anomaly information columns to the data
      # For every column specified in ``value_cols``, there will be 3 new columns are added to ``df``:
      # ``f"{value_col}_is_anomaly"``
      # ``f"{value_col}_anomaly_value"``
      # ``f"{value_col}_normal_value"``
      augmenting_data_res = label_anomalies_multi_metric(
          df=df,
          time_col=time_col,
          value_cols=value_cols,
          anomaly_df=anomaly_df,
          anomaly_df_grouping_col=anomaly_df_grouping_col,
          start_time_col=start_time_col,
          end_time_col=end_time_col,
      )
  
      augmented_df = augmenting_data_res["augmented_df"]
      is_anomaly_cols = augmenting_data_res["is_anomaly_cols"]
      anomaly_value_cols = augmenting_data_res["anomaly_value_cols"]
      normal_value_cols = augmenting_data_res["normal_value_cols"]
  
      line_colors = get_distinct_colors(
          len(value_cols), opacity=lines_opacity
      )
  
      marker_colors = get_distinct_colors(
          len(value_cols), opacity=markers_opacity
      )
  
      vrect_colors = get_distinct_colors(
          len(value_cols), opacity=vrect_opacity
      )
  
      fig = plot_lines_markers(
          df=augmented_df,
          x_col=time_col,
          line_cols=value_cols,
          marker_cols=anomaly_value_cols,
          line_colors=line_colors,
          marker_colors=marker_colors,
      )
  
      grouping_color_dict = {
          value_cols[i]: vrect_colors[i] for i in range(len(value_cols))
      }
  
      y_min = df[value_cols].min(numeric_only=True).min()
      y_max = df[value_cols].max(numeric_only=True).max()
  
      augmenting_fig_res = add_multi_vrects(
          fig=fig,
          periods_df=anomaly_df,
          grouping_col=anomaly_df_grouping_col,
          start_time_col=start_time_col,
          end_time_col=end_time_col,
          y_min=y_min,
          y_max=y_max,
          annotation_text_col=annotation_text_col,
          annotation_position="top left",
          opacity=1.0,
          grouping_color_dict=grouping_color_dict,
      )
  
      fig = augmenting_fig_res["fig"]
  
      return {
          "fig": fig,
          "augmented_df": augmented_df,
          "is_anomaly_cols": is_anomaly_cols,
          "anomaly_value_cols": anomaly_value_cols,
          "normal_value_cols": normal_value_cols,
          "line_colors": line_colors,
          "marker_colors": marker_colors,
          "vrect_colors": vrect_colors,
      }
  
file_path: greykite/greykite/common/viz/timeseries_annotate.py
imports: import pandas
  import plotly.graph_objects
  from greykite.common.constants import ACTUAL_COL
  from greykite.common.constants import ANOMALY_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import PREDICTED_ANOMALY_COL
  from greykite.common.constants import PREDICTED_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.features.adjust_anomalous_data import label_anomalies_multi_metric
  from greykite.common.viz.colors_utils import get_distinct_colors
  from greykite.common.viz.timeseries_plotting import plot_forecast_vs_actual
label_desc: Use image node_id 6 for calling a global function with example usage: plot_overlay_anomalies_multi_metric(df, time_col, value_cols, anomaly_df, anomaly_df_grouping_col, start_time_col, end_time_col, annotation_text_col, annotation_position, lines_opacity, markers_opacity, vrect_opacity) and returns: dict