code: def detect_beats(activations, interval, look_aside=0.2):
      """
      Detects the beats in the given activation function as in [1]_.
  
      Parameters
      ----------
      activations : numpy array
          Beat activations.
      interval : int
          Look for the next beat each `interval` frames.
      look_aside : float
          Look this fraction of the `interval` to each side to detect the beats.
  
      Returns
      -------
      numpy array
          Beat positions [frames].
  
      Notes
      -----
      A Hamming window of 2 * `look_aside` * `interval` is applied around the
      position where the beat is expected to prefer beats closer to the centre.
  
      References
      ----------
      .. [1] Sebastian Böck and Markus Schedl,
             "Enhanced Beat Tracking with Context-Aware Neural Networks",
             Proceedings of the 14th International Conference on Digital Audio
             Effects (DAFx), 2011.
  
      """
      # TODO: make this faster!
      sys.setrecursionlimit(len(activations))
      # always look at least 1 frame to each side
      frames_look_aside = max(1, int(interval * look_aside))
      win = np.hamming(2 * frames_look_aside)
  
      # list to be filled with beat positions from inside the recursive function
      positions = []
  
      def recursive(position):
          """
          Recursively detect the next beat.
  
          Parameters
          ----------
          position : int
              Start at this position.
  
          """
          # detect the nearest beat around the actual position
          act = signal_frame(
              activations, position, frames_look_aside * 2, 1
          )
          # apply a filtering window to prefer beats closer to the centre
          act = np.multiply(act, win)
          # search max
          if np.argmax(act) > 0:
              # maximum found, take that position
              position = np.argmax(act) + position - frames_look_aside
          # add the found position
          positions.append(position)
          # go to the next beat, until end is reached
          if position + interval < len(activations):
              recursive(position + interval)
          else:
              return
  
      # calculate the beats for each start position (up to the interval length)
      sums = np.zeros(interval)
      for i in range(interval):
          positions = []
          # detect the beats for this start position
          recursive(i)
          # calculate the sum of the activations at the beat positions
          sums[i] = np.sum(activations[positions])
      # take the winning start position
      start_position = np.argmax(sums)
      # and calc the beats for this start position
      positions = []
      recursive(start_position)
      # return indices
      return np.array(positions)
  
imports: from __future__ import absolute_import, division, print_function
  import sys
  import numpy
  from ..audio.signal import signal_frame, smooth
  from ..ml.nn import average_predictions
  from ..processors import OnlineProcessor, ParallelProcessor, Processor, SequentialProcessor
label_desc: Use image node_id 2 for calling a global function with example usage: detect_beats(activations, interval, look_aside) and returns: np