this code will break if n_jobs=-1. You need to overwrite the n_jobs by the one returned by parallel_func