def unpack_traces(traces):
	"""Returns states, actions, rewards, end_states, and a mask for episode boundaries given traces.""" 
	states = [t[0].state for t in traces]
	actions = [t[0].action for t in traces]
	rewards = [[e.reward for e in t] for t in traces]
	end_states = [t[-1].next_state for t in traces]
	not_done_mask = [[1 if n.next_state is not None else 0 for n in t] for t in traces]
	return states, actions, rewards, end_states, not_done_mask