def index2state(lookup, actions, nStates):
    """
    Converts state indexes back to tuples.

    Args:
        lookup (dict): Dictionary containing state-index pairs
        actions (list): List of actions (state indexes) to convert
        nStates (int): Number of states

    Returns
        sequence (list): List of converted tuples
    """
    keys = [0 for i in range(nStates)]
    for item in lookup.items():
        keys[item[1]] = item[0]
    sequence = []
    for action in actions:
        sequence.append(keys[action])

    return sequence