There are probably several ways, but the only method that will print in mind every word, every punctuation mark is repetitive writing.
Take poetry and write it from head to tail. (Depends on how long it is). Then take each verse and copy several times until it
starts to write without having to read each line. Then move to the next stanza, and the next .... When you finished all the stanzas begin to rewrite the poem in its entirety, and repeat the operation until you learn it.