batch_ids = ids[i_batch * batch_size:min((i_batch + 1) * batch_size, len(ids))]