code: def test_plot_anomalies_over_forecast_vs_actual():
      """Tests ``plot_anomalies_over_forecast_vs_actual`` function."""
      size = 200
      num_anomalies = 10
      num_predicted_anomalies = 15
      df = pd.DataFrame(
          {
              "ts": pd.date_range(
                  start="2018-01-01", periods=size, freq="H"
              ),
              "actual": np.random.normal(scale=10, size=size),
          }
      )
      df["forecast"] = df["actual"] + np.random.normal(size=size)
      df["forecast_lower"] = df["forecast"] - 10
      df["forecast_upper"] = df["forecast"] + 10
      df["is_anomaly"] = False
      df["is_anomaly_predicted"] = False
      df.loc[df.sample(num_anomalies).index, "is_anomaly"] = True
      df.loc[
          df.sample(num_predicted_anomalies).index,
          "is_anomaly_predicted",
      ] = True
  
      # Tests plots when both `predicted_anomaly_col` and `anomaly_col` are not None.
      fig = plot_anomalies_over_forecast_vs_actual(
          df=df,
          time_col="ts",
          actual_col="actual",
          predicted_col="forecast",
          predicted_lower_col="forecast_lower",
          predicted_upper_col="forecast_upper",
          predicted_anomaly_col="is_anomaly_predicted",
          anomaly_col="is_anomaly",
          predicted_anomaly_marker_color="lightblue",
          anomaly_marker_color="orange",
          marker_opacity=0.4,
      )
      assert len(fig.data) == 6
      # Checks the predicted anomaly data is correct.
      fig_predicted_anomaly_data = [
          data
          for data in fig.data
          if data["name"] == "is_anomaly_predicted".title()
      ][0]
      assert (
          len(fig_predicted_anomaly_data["x"])
          == num_predicted_anomalies
      )
      assert (
          fig_predicted_anomaly_data["marker"]["color"] == "lightblue"
      )
      assert fig_predicted_anomaly_data["opacity"] == 0.4
      # Checks the anomaly data is correct.
      fig_anomaly_data = [
          data
          for data in fig.data
          if data["name"] == "is_anomaly".title()
      ][0]
      assert len(fig_anomaly_data["x"]) == num_anomalies
      assert fig_anomaly_data["marker"]["color"] == "orange"
      assert fig_anomaly_data["opacity"] == 0.4
  
      # Tests plots when `predicted_anomaly_col` is None.
      fig = plot_anomalies_over_forecast_vs_actual(
          df=df,
          time_col="ts",
          actual_col="actual",
          predicted_col="forecast",
          predicted_lower_col="forecast_lower",
          predicted_upper_col="forecast_upper",
          predicted_anomaly_col=None,
          anomaly_col="is_anomaly",
      )
      assert len(fig.data) == 5
  
      # Tests plots when `anomaly_col` is None.
      fig = plot_anomalies_over_forecast_vs_actual(
          df=df,
          time_col="ts",
          actual_col="actual",
          predicted_col="forecast",
          predicted_lower_col="forecast_lower",
          predicted_upper_col="forecast_upper",
          predicted_anomaly_col="is_anomaly_predicted",
          anomaly_col=None,
      )
      assert len(fig.data) == 5
  
      # Tests plots when both `predicted_anomaly_col` and `anomaly_col` are None.
      fig = plot_anomalies_over_forecast_vs_actual(
          df=df,
          time_col="ts",
          actual_col="actual",
          predicted_col="forecast",
          predicted_lower_col="forecast_lower",
          predicted_upper_col="forecast_upper",
          predicted_anomaly_col=None,
          anomaly_col=None,
      )
      assert len(fig.data) == 4
  
imports: import numpy
  import pandas
  import pytest
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.python_utils import assert_equal
  from greykite.common.viz.colors_utils import get_distinct_colors
  from greykite.common.viz.timeseries_annotate import add_multi_vrects
  from greykite.common.viz.timeseries_annotate import plot_anomalies_over_forecast_vs_actual
  from greykite.common.viz.timeseries_annotate import plot_event_periods_multi
  from greykite.common.viz.timeseries_annotate import plot_lines_markers
  from greykite.common.viz.timeseries_annotate import plot_overlay_anomalies_multi_metric
  from greykite.common.viz.timeseries_annotate import plot_precision_recall_curve
  from greykite.common.viz.timeseries_annotate import plt_annotate_series
  from greykite.common.viz.timeseries_annotate import plt_compare_series_annotations
label_desc: Use image node_id 10 for calling a global function with example usage: test_plot_anomalies_over_forecast_vs_actual() without return types