code: def _parallel_evolve(
      n_programs, parents, X, y, sample_weight, seeds, params
  ):
      """Private function used to build a batch of programs within a job."""
      n_samples, n_features = X.shape
      # Unpack parameters
      tournament_size = params["tournament_size"]
      function_set = params["function_set"]
      arities = params["arities"]
      init_depth = params["init_depth"]
      init_method = params["init_method"]
      const_range = params["const_range"]
      metric = params["_metric"]
      transformer = params["_transformer"]
      parsimony_coefficient = params["parsimony_coefficient"]
      method_probs = params["method_probs"]
      p_point_replace = params["p_point_replace"]
      max_samples = params["max_samples"]
      feature_names = params["feature_names"]
  
      max_samples = int(max_samples * n_samples)
  
      def _tournament():
          """Find the fittest individual from a sub-population."""
          contenders = random_state.randint(
              0, len(parents), tournament_size
          )
          fitness = [parents[p].fitness_ for p in contenders]
          if metric.greater_is_better:
              parent_index = contenders[np.argmax(fitness)]
          else:
              parent_index = contenders[np.argmin(fitness)]
          return parents[parent_index], parent_index
  
      # Build programs
      programs = []
  
      for i in range(n_programs):
          random_state = check_random_state(seeds[i])
  
          if parents is None:
              program = None
              genome = None
          else:
              method = random_state.uniform()
              parent, parent_index = _tournament()
  
              if method < method_probs[0]:
                  # crossover
                  donor, donor_index = _tournament()
                  program, removed, remains = parent.crossover(
                      donor.program, random_state
                  )
                  genome = {
                      "method": "Crossover",
                      "parent_idx": parent_index,
                      "parent_nodes": removed,
                      "donor_idx": donor_index,
                      "donor_nodes": remains,
                  }
              elif method < method_probs[1]:
                  # subtree_mutation
                  program, removed, _ = parent.subtree_mutation(
                      random_state
                  )
                  genome = {
                      "method": "Subtree Mutation",
                      "parent_idx": parent_index,
                      "parent_nodes": removed,
                  }
              elif method < method_probs[2]:
                  # hoist_mutation
                  program, removed = parent.hoist_mutation(random_state)
                  genome = {
                      "method": "Hoist Mutation",
                      "parent_idx": parent_index,
                      "parent_nodes": removed,
                  }
              elif method < method_probs[3]:
                  # point_mutation
                  program, mutated = parent.point_mutation(random_state)
                  genome = {
                      "method": "Point Mutation",
                      "parent_idx": parent_index,
                      "parent_nodes": mutated,
                  }
              else:
                  # reproduction
                  program = parent.reproduce()
                  genome = {
                      "method": "Reproduction",
                      "parent_idx": parent_index,
                      "parent_nodes": [],
                  }
  
          program = _Program(
              function_set=function_set,
              arities=arities,
              init_depth=init_depth,
              init_method=init_method,
              n_features=n_features,
              metric=metric,
              transformer=transformer,
              const_range=const_range,
              p_point_replace=p_point_replace,
              parsimony_coefficient=parsimony_coefficient,
              feature_names=feature_names,
              random_state=random_state,
              program=program,
          )
  
          program.parents = genome
  
          # Draw samples, using sample weights, and then fit
          if sample_weight is None:
              curr_sample_weight = np.ones((n_samples,))
          else:
              curr_sample_weight = sample_weight.copy()
          oob_sample_weight = curr_sample_weight.copy()
  
          indices, not_indices = program.get_all_indices(
              n_samples, max_samples, random_state
          )
  
          curr_sample_weight[not_indices] = 0
          oob_sample_weight[indices] = 0
  
          program.raw_fitness_ = program.raw_fitness(
              X, y, curr_sample_weight
          )
          if max_samples < n_samples:
              # Calculate OOB fitness
              program.oob_fitness_ = program.raw_fitness(
                  X, y, oob_sample_weight
              )
  
          programs.append(program)
  
      return programs
  
imports: import itertools
  from abc import ABCMeta, abstractmethod
  from time import time
  from warnings import warn
  import numpy
  from joblib import Parallel, delayed
  from scipy.stats import rankdata
  from sklearn.base import BaseEstimator
  from sklearn.base import RegressorMixin, TransformerMixin, ClassifierMixin
  from sklearn.exceptions import NotFittedError
  from sklearn.utils import compute_sample_weight
  from sklearn.utils.validation import check_array, _check_sample_weight
  from sklearn.utils.multiclass import check_classification_targets
  from ._program import _Program
  from .fitness import _fitness_map, _Fitness
  from .functions import _function_map, _Function, sig1
  from .utils import _partition_estimators
  from .utils import check_random_state
label_desc: Use image node_id 1 for calling a global function with example usage: _parallel_evolve(n_programs, parents, X, y, sample_weight, seeds, params) and returns: programs, parents,  parent_index