Similar Items: Learning the bistable cortical dynamics of the sleep-onset period