human
Solve the following python programming problem given the following code:
# It would be easy enough to set up the dask hooks for by_session, but right now it's only done for by_event.
# So don't change these or it won't work.
parallelize_by_session = False # won't work currently with Dask
parallelize_by_event = True

n_jobs = 20 # set this equal to number of cores (or number of workers if using the dask-distribued joblib backend)
n_shuffles = 2 # 5000
n_samples = 100 # 35000
w=3 # single sided bandwidth (0 means only include bin who's center is under line, 3 means a total of 7 bins)

from dask.distributed import Client
# client = Client('dask-scheduler:8786') # fill in value from dask-kubernetes startup if connecting remotely
client = Client() # Use this to create a local scheduluer
client

# Not set up for dask!!!

if parallelize_by_session:
    from joblib import Parallel, delayed 

    # A function that can be called to do work:
    def work_sessions(arg):    

        # Split the list to individual variables:
        ii, bst, tc = arg    

        scores, shuffled_scores, percentiles = nel.analysis.replay.score_Davidson_final_bst_fast(bst=bst,
                                                                                            tuningcurve=tc,
                                                                                            w=w,
                                                                                            n_shuffles=n_shuffles,
                                                                                            n_samples=n_samples)

        return (ii, scores, shuffled_scores, percentiles)

    # List of instances to pass to work():
    parallel_sessions = [(ii, aux_data[session][segment]['PBEs'], aux_data[session][segment]['tc']) for (ii, (session, segment)) in enumerate(zip(sessions, segments))]

    parallel_results = Parallel(n_jobs=n_jobs, verbose=51)(map(delayed(work_sessions), parallel_sessions))

    # standardize parallel results
    idx = [result[0] for result in parallel_results]

    # check that parallel results came back IN...
Given the above code, generate some markdown instructions for it.
assistant
#Here is the Python program you requested.

Parallel scoring
NOTE: it is relatively easy (syntax-wise) to score each session as a parallel task, but since the Bayesian scoring takes such a long time to compute, we can be more efficient (higher % utilization) by further parallelizing over events, and not just over sessions. This further level of parallelization makes the bookkeeping a little ugly, so I provide the code for both approaches here.