minibatch transformer for better memory efficiency