Accessing state_history

In a policy function, what’s the correct way to access a specific variable in state_history?
Simply aiming to calculate an average over time X.

Thanks!