code: def prep_samples_and_config(run_folder, ldetails, fastq_dir, config):
      
      fastq_final_dir = utils.safe_makedir(os.path.join(fastq_dir, "merged"))
      cores = utils.get_in(config, ("algorithm", "num_cores"), 1)
      ldetails = joblib.Parallel(cores)(joblib.delayed(_prep_sample_and_config)(x, fastq_dir, fastq_final_dir)
                                        for x in _group_same_samples(ldetails))
      config_file = _write_sample_config(run_folder, [x for x in ldetails if x])
      return config_file, fastq_final_dir
docs: Prepare sample fastq files and provide global sample configuration for the flowcell.
  
      Handles merging of fastq files split by lane and also by the bcl2fastq
      preparation process.