import random


def form_batches(batch_size, idx):
    """Shuffles idx list into minibatches each of size batch_size"""
    idxs = [i for i in idx]
    random.shuffle(idxs)
    return [idxs[i:(i+batch_size)] for i in range(0,len(idxs),batch_size)]