code: def test_z_score_outlier_detector(data):
      """Tests `ZScoreOutlierDetector` usage."""
      # Default setting and easy detection.
      detect_outlier = ZScoreOutlierDetector()
  
      # Easy detection example.
      y = data["y_easy_outlier"].copy()
      y_test = data["y_easy_outlier_test"].copy()
  
      detect_outlier.fit(y)
      assert (
          abs(detect_outlier.fitted_param["trimmed_mean"] - 0.12188)
          < 0.1
      )
      assert (
          abs(detect_outlier.fitted_param["trimmed_sd"] - 2.202187)
          < 0.1
      )
  
      detect_outlier.detect(y_test)
  
      fitted = detect_outlier.fitted
      predicted = detect_outlier.predicted
  
      fig = helper_plot_outliers(
          y=y, detection_result=fitted, title="Easy detection Z-score"
      )
      if FIG_SHOW:
          fig.show()
      assert fig is not None
  
      # We expect only an outlier in second position as per `data` definition.
      assert fitted.is_outlier[2]
      assert sum(fitted.is_outlier) == 1
  
      # We expect only an outlier in 5th position as per `data` definition.
      assert predicted.is_outlier[5]
      assert sum(predicted.is_outlier) == 1
  
      # Hard detection example without differencing.
      # Here we expect that the outlier is not removed.
      # This will showcase how without differencing anomaly is missed.
      y = data["y_hard_outlier"].copy()
      y_test = data["y_hard_outlier_test"].copy()
  
      detect_outlier = ZScoreOutlierDetector(diff_method=None)
      detect_outlier.fit(y)
      detect_outlier.detect(y_test)
  
      fitted = detect_outlier.fitted
      predicted = detect_outlier.predicted
      # We note that the trimmed mean and sd are quite large since no diffing is done.
      assert (
          abs(detect_outlier.fitted_param["trimmed_mean"] - 50.5917)
          < 0.1
      )
      assert (
          abs(detect_outlier.fitted_param["trimmed_sd"] - 26.8908) < 0.1
      )
  
      fig = helper_plot_outliers(
          y=y,
          detection_result=fitted,
          title="Hard detection with Z-score and no baseline diffing.",
      )
      if FIG_SHOW:
          fig.show()
      assert fig is not None
  
      # We expect no outlier is detected.
      assert not fitted.is_outlier[2]
      assert sum(fitted.is_outlier) == 0
  
      # We expect no outlier is detected.
      assert not predicted.is_outlier[5]
      assert sum(predicted.is_outlier) == 0
  
      # Hard detection example with differencing (default behavior).
      # Here we expect that the outlier is removed.
      # This will showcase how how differencing with appropriate baseline is helpful.
      y = data["y_hard_outlier"]
      y_test = data["y_hard_outlier_test"]
  
      detect_outlier = ZScoreOutlierDetector()
      detect_outlier.fit(y)
      detect_outlier.detect(y_test)
  
      fitted = detect_outlier.fitted
      predicted = detect_outlier.predicted
      # Due to diffing, the mean and sd are much smaller.
      assert (
          abs(detect_outlier.fitted_param["trimmed_mean"] - 0.12188)
          < 0.1
      )
      assert (
          abs(detect_outlier.fitted_param["trimmed_sd"] - 2.202187)
          < 0.1
      )
  
      fig = helper_plot_outliers(
          y=y,
          detection_result=fitted,
          title="Hard detection with Z-score with diffing.",
      )
      if FIG_SHOW:
          fig.show()
      assert fig is not None
  
      # We expect only an outlier in second position as per `data` definition.
      assert fitted.is_outlier[2]
      assert sum(fitted.is_outlier) == 1
  
      # We expect only an outlier in 5th position as per `data` definition.
      assert predicted.is_outlier[5]
      assert sum(predicted.is_outlier) == 1
  
imports: import numpy
  import pandas
  import pytest
  from greykite.common.features.outlier import EXPONENTIAL_SMOOTHING
  from greykite.common.features.outlier import MOVING_MEDIAN
  from greykite.common.features.outlier import BaseOutlierDetector
  from greykite.common.features.outlier import DetectionResult
  from greykite.common.features.outlier import DiffMethod
  from greykite.common.features.outlier import TukeyOutlierDetector
  from greykite.common.features.outlier import ZScoreOutlierDetector
  from greykite.common.viz.timeseries_annotate import plot_lines_markers
label_desc: Use image node_id 12 for calling a global function with example usage: test_z_score_outlier_detector(data) without return types