code: def _calculate_apm(index, player_actions, other_actions, duration):
      
      apm_per_player = {}
      for player_index, histogram in player_actions.items():
          apm_per_player[player_index] = sum(histogram.values())
      total_unattributed = sum(other_actions.values())
      total_attributed = sum(apm_per_player.values())
      player_proportion = apm_per_player[index] / total_attributed
      player_unattributed = total_unattributed * player_proportion
      apm = (apm_per_player[index] + player_unattributed) / (duration / 60)
      return int(apm)
docs: Calculate player's rAPM.