<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _calculate_apm(index, player_actions, other_actions, duration):
 """Calculate player's rAPM."""

    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)