hat, pick (something) out of the

(informal) get (something) as if by magic; invent; imagine.