get_batches_index function

Assign cases to batches