How to train RNNs with mini-batches?

I am following for an introduction to LSTMs.
Now I am wondering how would one change this tutorial to include mini-batch training (with in the most efficient way? Do I have to manually iterate over the LSTM output to feed the linear layer? (In the given implementation the sequence-dimension from the LSTM is used as the batch-dimension of the linear layer)