How do you get the chaos emeralds?

Usually From A Special Stage, Which Game Are You Talking About?