code: def get_positional_reward(
      loc: int, anomaly_length: int, positional_bias: str = "flat"
  ):
      """Positional reward for a single pointwise anomaly with an anomaly range
  
      Parameters
      ----------
      loc : `int`
          Location of the pointwise anomaly, within the anomaly range. Takes value in the range[1, anomaly_length]
      anomaly_length: `int`
          Length of the anomaly range used to score a pointwise anomaly within it.
      positional_bias : `str`, default "flat"
          The accepted options are:
          * "flat": Each index position of an anomaly range is equally important. Return the same value of 1.0 as the positional
            reward regardless of the location of the pointwise anomaly within the anomaly range.
          * "front": Positional reward is biased towards early detection, as earlier overlap locations of pointwise
            anomalies with an anomaly range are assigned higher rewards.
          * "middle": Positional reward is biased towards the detection of anomaly closer to its middle point, as overlap locations
            closer to the middle of an anomaly range are assigned higher rewards.
          * "back":  Positional reward is biased towards later detection, as later overlap locations of pointwise anomalies with an
            anomaly range are assigned higher rewards.
  
      Returns
      -------
      positional_reward: `float`
          Positional reward for the pointwise anomaly within an anomaly range.
      """
  
      assert 1 <= loc <= anomaly_length
      positional_reward = 1.0
  
      if positional_bias == "flat":
          return positional_reward
      elif positional_bias == "front":
          positional_reward = float(anomaly_length - loc + 1.0)
      elif positional_bias == "middle":
          if loc <= anomaly_length / 2.0:
              positional_reward = float(loc)
          else:
              positional_reward = float(anomaly_length - loc + 1.0)
      elif positional_bias == "back":
          positional_reward = float(loc)
      else:
          raise Exception("Invalid positional bias value")
      return positional_reward
  
file_path: greykite/greykite/detection/common/ad_evaluation_utils.py
imports: from typing import List
  from typing import Optional
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: get_positional_reward(loc, anomaly_length, positional_bias) and returns: positional_reward, positional_reward