Mini Batches respecting class proportion/frequency

I have currently found the answer here: