code: def test_compute_range_based_score():
      """Tests for compute_range_based_score function"""
  
      y_true = np.array(
          [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0]
      )
      y_pred = np.array(
          [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0]
      )
  
      real_anomaly_ranges = prepare_anomaly_ranges(y_true)
      predicted_anomaly_ranges = prepare_anomaly_ranges(y_pred)
  
      recall = compute_range_based_score(
          real_anomaly_ranges,
          predicted_anomaly_ranges,
          alpha=0.5,
          positional_bias="flat",
      )
      precision = compute_range_based_score(
          predicted_anomaly_ranges,
          real_anomaly_ranges,
          alpha=0.5,
          positional_bias="flat",
      )
      assert round(precision, 3) == 0.958
      assert round(recall, 3) == 0.806
  
      recall = compute_range_based_score(
          real_anomaly_ranges,
          predicted_anomaly_ranges,
          alpha=0.5,
          positional_bias="front",
      )
      precision = compute_range_based_score(
          predicted_anomaly_ranges,
          real_anomaly_ranges,
          alpha=0.5,
          positional_bias="front",
      )
      assert round(precision, 3) == 0.933
      assert round(recall, 3) == 0.867
  
      recall = compute_range_based_score(
          real_anomaly_ranges,
          predicted_anomaly_ranges,
          alpha=0.5,
          positional_bias="middle",
      )
      precision = compute_range_based_score(
          predicted_anomaly_ranges,
          real_anomaly_ranges,
          alpha=0.5,
          positional_bias="middle",
      )
      assert round(precision, 3) == 0.972
      assert round(recall, 3) == 0.817
  
      recall = compute_range_based_score(
          real_anomaly_ranges,
          predicted_anomaly_ranges,
          alpha=0.5,
          positional_bias="back",
      )
      precision = compute_range_based_score(
          predicted_anomaly_ranges,
          real_anomaly_ranges,
          alpha=0.5,
          positional_bias="back",
      )
      assert round(precision, 3) == 0.983
      assert round(recall, 3) == 0.746
  
      recall = compute_range_based_score(
          real_anomaly_ranges,
          predicted_anomaly_ranges,
          alpha=0.5,
          positional_bias="front",
          cardinality_bias="reciprocal",
      )
      precision = compute_range_based_score(
          predicted_anomaly_ranges,
          real_anomaly_ranges,
          alpha=0.5,
          positional_bias="front",
          cardinality_bias="reciprocal",
      )
      assert round(precision, 3) == 0.933
      assert round(recall, 3) == 0.783
  
file_path: greykite/greykite/tests/detection/common/test_ad_evaluation_utils.py
imports: import numpy
  from greykite.detection.common.ad_evaluation_utils import compute_range_based_score
  from greykite.detection.common.ad_evaluation_utils import get_cardinality_factor
  from greykite.detection.common.ad_evaluation_utils import get_overlap_size_and_position_reward
  from greykite.detection.common.ad_evaluation_utils import get_positional_reward
  from greykite.detection.common.ad_evaluation_utils import prepare_anomaly_ranges
label_desc: Use image node_id 5 for calling a global function with example usage: test_compute_range_based_score() without return types