code: def test_get_overlap_size_and_position_reward():
      """Tests for get_overlap_size_and_position_reward function"""
  
      # No overlap produces an overlap_size_and_position_reward of zero
      anomaly_range_1 = np.array([3, 8])
      anomaly_range_2 = np.array([9, 10])
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="flat",
          )
      )
      assert overlap_size_and_position_reward == 0
  
      # Overlap of anomaly_range_2 with anomaly_range_1 happens at the beginning of anomaly_range_1
      # This overlap yields higher size and positional reward when positional bias is set to "front" than when
      # set to "middle" or "back".
      anomaly_range_1 = np.array([3, 8])
      anomaly_range_2 = np.array([3, 5])
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="front",
          )
      )
      assert round(overlap_size_and_position_reward, 3) == 0.714
  
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="middle",
          )
      )
      assert round(overlap_size_and_position_reward, 3) == 0.50
  
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="back",
          )
      )
      assert round(overlap_size_and_position_reward, 3) == 0.286
  
      # Overlap of anomaly_range_2 with anomaly_range_1 happens at the end of anomaly_range_1
      # This overlap yields higher size and positional reward when positional bias is set to "back" than when
      # set to "middle" or "front".
      anomaly_range_1 = np.array([3, 8])
      anomaly_range_2 = np.array([5, 9])
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="front",
          )
      )
      assert round(overlap_size_and_position_reward, 3) == 0.476
  
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="middle",
          )
      )
      assert round(overlap_size_and_position_reward, 3) == 0.75
  
      overlap_size_and_position_reward = (
          get_overlap_size_and_position_reward(
              anomaly_range_1=anomaly_range_1,
              anomaly_range_2=anomaly_range_2,
              overlap_count=[0],
              positional_bias="back",
          )
      )
      assert round(overlap_size_and_position_reward, 3) == 0.857
  
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 4 for calling a global function with example usage: test_get_overlap_size_and_position_reward() without return types