code: def _mean_match_binary_accurate(
      mean_match_candidates,
      bachelor_preds,
      candidate_preds,
      candidate_values,
      random_state,
      hashed_seeds,
  ):
      """
      Determines the values of candidates which will be used to impute the bachelors
      """
  
      if mean_match_candidates == 0:
          imp_values = np.floor(bachelor_preds + 0.5)
  
      else:
          _to_2d(bachelor_preds)
          _to_2d(candidate_preds)
  
          num_bachelors = bachelor_preds.shape[0]
  
          # balanced_tree = False fixes a recursion issue for some reason.
          # https://github.com/scipy/scipy/issues/14799
          kd_tree = KDTree(
              candidate_preds, leafsize=16, balanced_tree=False
          )
          _, knn_indices = kd_tree.query(
              bachelor_preds, k=mean_match_candidates, workers=-1
          )
  
          # We can skip the random selection process if mean_match_candidates == 1
          if mean_match_candidates == 1:
              index_choice = knn_indices
  
          else:
              # Use the random_state if seed_array was not passed. Faster
              if hashed_seeds is None:
                  ind = random_state.randint(
                      mean_match_candidates, size=(num_bachelors)
                  )
              # Use the random_seed_array if it was passed. Deterministic.
              else:
                  ind = hashed_seeds % mean_match_candidates
  
              index_choice = knn_indices[np.arange(num_bachelors), ind]
  
          imp_values = np.array(candidate_values)[index_choice]
  
      return imp_values
  
imports: import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: _mean_match_binary_accurate(mean_match_candidates, bachelor_preds, candidate_preds, candidate_values, random_state, hashed_seeds) and returns: imp_values