The last lines of A Midsummer Night`s Dream constitute what is known as an epilogue (literally, after-speech) to the play. Typically, Shakespeare writes these in the rhymed forms of lyric songs rather than the blank verse he uses for dialogue. It was probably sung or accompanied with music in performance, and its metrical structure resembles that of many other song lyrics of the period.
The first couplet of the epilogue is in regular trochaic tetrameter:
If we shadows have offended,
Think but this and all is mended:
The subsequent lines are a bit more complicated. The middle group are heptasyllabic rhymed couplets:
Gentles, do not reprehend.
If you pardon, we will mend.
And, as I am an honest Puck,
If we have unearned luck
Whether these should be considered catalectic (missing last, usually weak, syllable) trochaic tetrameter or acephalous iambic tetrameter is uncertain, though given its frequency in Elizabethan and Jacobean verse, it should be treated as a standard line form rather than a metrical variation.
The last two lines are iambic tetrameter:
Give me your hands, if we be friends,
And Robin shall restore amends.