Fix `filter` with multiprocessing in case all samples are discarded
Fixes #2600 

Also I moved the check for `num_proc` larger than dataset size added in #2566 up so that multiprocessing is not used with one process.