code: def balanced_scheduling(time_cost_pred, n_estimators, n_jobs):
      """Conduct balanced scheduling based on the sum of rank, for both train
      and prediction. The algorithm will enforce the equal sum of ranks among
      workers.
  
      Parameters
      ----------
      time_cost_pred
      n_estimators
      n_jobs
  
      Returns
      -------
  
      """
      n_jobs = min(effective_n_jobs(n_jobs), n_estimators)
      # Conduct Balanced Task Scheduling
      n_estimators_list = (
          []
      )  # track the number of estimators for each worker
      ranks = rankdata(time_cost_pred)
      ##########################################
      # #todo: the fastest is at most 2 times costly than the slowest
      ranks = 1 + ranks / n_estimators
      ##########################################
      rank_sum = np.sum(ranks)
      chunk_sum = rank_sum / n_jobs
  
      starts_orig = [0]
      index_track = 0
      sum_check = []
  
      for i in range(len(ranks) + 1):
          if np.sum(ranks[starts_orig[index_track] : i]) >= chunk_sum:
              starts_orig.append(i)
              index_track += 1
      starts_orig.append(len(ranks))
  
      starts = starts_orig
  
      # # offset for the last worker's load
      # starts = [0]
      # for k in range(1, n_jobs+1):
      #     starts.append(starts_orig[k]-np.random.randint(low=1, high=k+1))
  
      # print(starts)
      # starts[-1] = n_estimators
      # print(starts)
  
      for j in range(n_jobs):
          sum_check.append(np.sum(ranks[starts[j] : starts[j + 1]]))
          print("Worker", j + 1, "sum of ranks:", sum_check[j])
          n_estimators_list.append(starts[j + 1] - starts[j])
  
      print()
  
      # Confirm the length of the estimators is consistent
      assert np.sum(n_estimators_list) == n_estimators
      assert np.abs(rank_sum - np.sum(sum_check)) < 0.1
  
      xdiff = [starts[n] - starts[n - 1] for n in range(1, len(starts))]
  
      print("Split among workers BPS:", starts, xdiff)
      return n_estimators_list, starts, n_jobs
  
imports: import os
  import sys
  import time
  import warnings
  import arff
  import joblib
  import numpy
  import scipy
  from joblib import Parallel, delayed
  from joblib import effective_n_jobs
  from pyod.models.abod import ABOD
  from pyod.models.cblof import CBLOF
  from pyod.models.feature_bagging import FeatureBagging
  from pyod.models.hbos import HBOS
  from pyod.models.iforest import IForest
  from pyod.models.knn import KNN
  from pyod.models.lof import LOF
  from pyod.models.mcd import MCD
  from pyod.models.ocsvm import OCSVM
  from pyod.models.pca import PCA
  from scipy.stats import rankdata
  from sklearn.base import clone
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils import check_array
label_desc: Use image node_id 3 for calling a global function with example usage: balanced_scheduling(time_cost_pred, n_estimators, n_jobs) and returns: n_estimators_list,  starts,  n_jobs