def initialize_rewards(nS, nA):
    """Initializes a rewards array. Values represent running averages.

    Parameters
    ----------
    nS: int
        Number of states
    nA: int
        Number of actions

    Returns
    -------
    rewards: array of shape [nS x nA x nS]
        counts[state][action][next_state] is the running average of rewards of doing "action" at "state" transtioned to "next_state"
    """
    rewards = [[[0 for _ in range (nS)] for _ in range(nA)] for _ in range(nS)]

    return rewards