code: def test_normal_detector():
      """Tests `NormalDetector` class.
      This test is to demonstrate the usage of the `Detector` class."""
      size = 500
      np.random.seed(1317)
      y = np.random.normal(loc=0.0, scale=1.0, size=size)
      df = pd.DataFrame({"y": y})
      anomaly_percent_dict = {"range": (4, 6), "penalty": -1.0}
  
      detector = NormalDetector(
          value_col="y", anomaly_percent_dict=anomaly_percent_dict
      )
  
      reward = detector.reward
      x = reward.apply(Data(y_pred=[True, True, False, False]))
      assert x == -1.45
  
      x = reward.apply(Data(y_pred=[True] * 5 + [False] * 95))
      assert x == 0
  
      x = reward.apply(Data(y_pred=[True] * 6 + [False] * 94))
      assert x == -0.01
  
      x = reward.apply(Data(y_pred=[True] * 4 + [False] * 96))
      assert x == -0.01
  
      detector.fit(Data(df=df))
      assert detector.value_col == "y"
  
      param_full = detector.fit_info["param_full"]
      assert round(param_full["err"], 2) == 1.89
      assert round(param_full["prob_thresh"], 3) == 0.965
  
      param_obj_list = detector.fit_info["param_obj_list"]
      param_obj_df = pd.DataFrame.from_records(param_obj_list)
      fig = plot_lines_markers(
          df=param_obj_df, x_col="prob_thresh", line_cols=["obj_value"]
      )
      fig.layout.update(
          title="'NormalDetector' parameter search for prob_thresh"
      )
      assert fig is not None
  
imports: import numpy
  import pandas
  import pytest
  from scipy import stats
  from greykite.common.constants import PREDICTED_ANOMALY_COL
  from greykite.common.viz.timeseries_annotate import plot_lines_markers
  from greykite.detection.common.ad_evaluation import f1_score
  from greykite.detection.detector.data import DetectorData
  from greykite.detection.detector.detector import Detector
  from greykite.detection.detector.detector import build_anomaly_percent_reward
  from greykite.detection.detector.optimizer import CalcResult
  from greykite.detection.detector.reward import Reward
label_desc: Use image node_id 3 for calling a global function with example usage: test_normal_detector() without return types