code: def filter_ensemble_classification(
      predictor,
      unlabeled_data: pd.DataFrame,
      leaderboard,
      num_models,
      threshold: float = 0.95,
  ):
      """
      Calculates predictive probabilities of unlabeled data by predicting with top num_models
      then averages pre-row over predictions from top num_models and selects rows where confidence
      (predicted probability of the most likely class) is above threshold. Then samples minimum
      bin count from all bins, where bins are rows of averaged predictions with the same peak
      predicted probability class.
  
      Parameters:
      -----------
      predictor: Fitted TabularPredictor
      unlabeled_data: Unlabeled data for top k models to predict on
      leaderboard: pd.DataFrame of leaderboard of models in AutoGluon based on validation score
      num_models: Number of top models to ensemble
      threshold: The predictive probability a row must exceed in order to be
          selected
  
      Returns:
      --------
      pd.Series of indices that met pseudo labeling requirements
      """
      top_k_model_names = leaderboard.head(num_models)["model"]
  
      y_pred_proba_ensemble = None
      for model_name in top_k_model_names:
          y_pred_proba_curr_model = predictor.predict_proba(
              data=unlabeled_data, model=model_name
          )
  
          if y_pred_proba_ensemble is None:
              y_pred_proba_ensemble = y_pred_proba_curr_model
          else:
              y_pred_proba_ensemble += y_pred_proba_curr_model
  
      # Todo: This doesn't make total sense, because weighted ensemble
      # will ensemble the top models and weigh them according to validation score
      # maybe should just force prediction using weighted ensemble instead of
      # uniform across top k?
      y_pred_proba_ensemble /= num_models
      y_max_prob = y_pred_proba_ensemble.max(axis=1)
      pseudo_indexes = y_max_prob >= threshold
      y_pred_ensemble = y_pred_proba_ensemble.idxmax(axis=1)
  
      test_pseudo_indices = sample_bins_uniformly(
          y_pred_proba=y_pred_proba_ensemble, df_indexes=pseudo_indexes
      )
  
      return (
          test_pseudo_indices[test_pseudo_indices],
          y_pred_proba_ensemble,
          y_pred_ensemble,
      )
  
file_path: autogluon/core/src/autogluon/core/pseudolabeling/pseudolabeling.py
imports: import logging
  import numpy
  import pandas
  from autogluon.core.constants import PROBLEM_TYPES_CLASSIFICATION
label_desc: Use image node_id 5 for calling a global function with example usage: filter_ensemble_classification(predictor, unlabeled_data, leaderboard, num_models, threshold) and returns: test_pseudo_indices,  y_pred_proba_ensemble,  y_pred_ensemble