import copy
import random


def get_initial_state(initial_states, n=None):
    """ return an initial state from the initial_states argument """
    state_copy = copy.deepcopy(initial_states)
    if isinstance(state_copy, list):
        if n is not None and len(state_copy) > n:
            return state_copy[n]
        else:
            return random.choice(state_copy)
    elif isinstance(state_copy, dict):
        return state_copy
    else:
        return {}