Inversion is a change from the usual order of sentence elements. In English, a common kind puts an auxiliary before the subject. Compare The lights are flashing with Are the lights flashing?

How to recognize it
Compare the order with an ordinary statement. If an auxiliary or main verb precedes the subject in the relevant pattern, the order is inverted.
Examples explained
Where inversion occurs
Many direct questions. In Did Eli call?, the auxiliary comes before Eli. In Who called?, the question word is the subject and comes first.
Some opening negative expressions. Never have we seen the river so high. The opening never brings have before the subject we.
Some formal conditionals. Had we left earlier, we would have caught the ferry means If we had left earlier, we would have caught the ferry.
Inversion without an auxiliary
In On the porch stood two bicycles, the location comes first and the main verb stood precedes the subject two bicycles. This differs from On the porch, two bicycles stood side by side, where the opening location leaves the subject before the verb. See interrogative sentences and conditionals for related patterns.
Common mix-up
Moving a location to the front does not always invert subject and verb. On the porch, two bicycles stood keeps the subject first.
Quick check
Which word moves before the subject in “Are the lights flashing?”
Reveal the answer and explanation
Are, the auxiliary, comes before the lights. Compare The lights are flashing.