Theory of heavy quark production in collisions