code: def test_build_anomaly_percent_reward():
      anomaly_percent_dict = {"range": (4, 6), "penalty": -1}
      reward = build_anomaly_percent_reward(anomaly_percent_dict)
  
      assert reward.min_unpenalized == -0.01
      assert reward.max_unpenalized == float("inf")
      assert reward.penalty == -1
  
      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
  
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 1 for calling a global function with example usage: test_build_anomaly_percent_reward() without return types