code: def get_active_learning_scores(
      labels_multiannotator: Optional[
          Union[pd.DataFrame, np.ndarray]
      ] = None,
      pred_probs: Optional[np.ndarray] = None,
      pred_probs_unlabeled: Optional[np.ndarray] = None,
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Returns an ActiveLab quality score for each example in the dataset, to estimate which examples are most informative to (re)label next in active learning.
  
      We consider settings where one example can be labeled by one or more annotators and some examples have no labels at all so far.
  
      The score is in between 0 and 1, and can be used to prioritize what data to collect additional labels for.
      Lower scores indicate examples whose true label we are least confident about based on the current data;
      collecting additional labels for these low-scoring examples will be more informative than collecting labels for other examples.
      To use an annotation budget most efficiently, select a batch of examples with the lowest scores and collect one additional label for each example,
      and repeat this process after retraining your classifier.
  
      You can use this function to get active learning scores for: examples that already have one or more labels (specify ``labels_multiannotator`` and ``pred_probs``
      as arguments), or for unlabeled examples (specify ``pred_probs_unlabeled``), or for both types of examples (specify all of the above arguments).
  
      To analyze a fixed dataset labeled by multiple annotators rather than collecting additional labels, try the
      `~cleanlab.multiannotator.get_label_quality_multiannotator` (CROWDLAB) function instead.
  
      Parameters
      ----------
      labels_multiannotator : pd.DataFrame or np.ndarray, optional
          2D pandas DataFrame or array of multiple given labels for each example with shape ``(N, M)``,
          where N is the number of examples and M is the number of annotators. Note that this function also works with
          datasets where there is only one annotator (M=1).
          For more details, labels in the same format expected by the `~cleanlab.multiannotator.get_label_quality_multiannotator`.
          Note that examples that have no annotator labels should not be included in this DataFrame/array.
          This argument is optional if ``pred_probs`` is not provided (you might only provide ``pred_probs_unlabeled`` to only get active learning scores for the unlabeled examples).
      pred_probs : np.ndarray, optional
          An array of shape ``(N, K)`` of predicted class probabilities from a trained classifier model.
          Predicted probabilities in the same format expected by the :py:func:`get_label_quality_scores <cleanlab.rank.get_label_quality_scores>`.
          This argument is optional if you only want to get active learning scores for unlabeled examples (specify only ``pred_probs_unlabeled`` instead).
      pred_probs_unlabeled : np.ndarray, optional
          An array of shape ``(N, K)`` of predicted class probabilities from a trained classifier model for examples that have no annotator labels.
          Predicted probabilities in the same format expected by the :py:func:`get_label_quality_scores <cleanlab.rank.get_label_quality_scores>`.
          This argument is optional if you only want to get active learning scores for already-labeled examples (specify only ``pred_probs`` instead).
  
      Returns
      -------
      active_learning_scores : np.ndarray
          Array of shape ``(N,)`` indicating the ActiveLab quality scores for each example.
          This array is empty if no already-labeled data was provided via ``labels_multiannotator``.
          Examples with the lowest scores are those we should label next in order to maximally improve our classifier model.
  
      active_learning_scores_unlabeled : np.ndarray
          Array of shape ``(N,)`` indicating the active learning quality scores for each unlabeled example.
          Returns an empty array if no unlabeled data is provided.
          Examples with the lowest scores are those we should label next in order to maximally improve our classifier model
          (scores for unlabeled data are directly comparable with the `active_learning_scores` for labeled data).
      """
  
      assert_valid_pred_probs(
          pred_probs=pred_probs,
          pred_probs_unlabeled=pred_probs_unlabeled,
      )
  
      # compute multiannotator stats if labeled data is provided
      if pred_probs is not None:
          if labels_multiannotator is None:
              raise ValueError(
                  "labels_multiannotator cannot be None when passing in pred_probs. ",
                  "Either provide labels_multiannotator to obtain active learning scores for the labeled examples, "
                  "or just pass in pred_probs_unlabeled to get active learning scores for unlabeled examples.",
              )
  
          if isinstance(labels_multiannotator, pd.DataFrame):
              labels_multiannotator = (
                  labels_multiannotator.replace({pd.NA: np.NaN})
                  .astype(float)
                  .to_numpy()
              )
          elif not isinstance(labels_multiannotator, np.ndarray):
              raise ValueError(
                  "labels_multiannotator must be either a NumPy array or Pandas DataFrame."
              )
          # check that labels_multiannotator is a 2D array
          if labels_multiannotator.ndim != 2:
              raise ValueError(
                  "labels_multiannotator must be a 2D array or dataframe, "
                  "each row represents an example and each column represents an annotator."
              )
  
          num_classes = get_num_classes(pred_probs=pred_probs)
  
          # if all examples are only labeled by a single annotator
          if (
              np.sum(~np.isnan(labels_multiannotator), axis=1) == 1
          ).all():
              optimal_temp = 1.0  # do not temp scale for single annotator case, temperature is defined here for later use
  
              assert_valid_inputs_multiannotator(
                  labels_multiannotator,
                  pred_probs,
                  allow_single_label=True,
              )
  
              consensus_label = get_majority_vote_label(
                  labels_multiannotator=labels_multiannotator,
                  pred_probs=pred_probs,
                  verbose=False,
              )
              quality_of_consensus_labeled = get_label_quality_scores(
                  consensus_label, pred_probs
              )
              model_weight = 1
              annotator_weight = np.full(
                  labels_multiannotator.shape[1], 1
              )
              avg_annotator_weight = np.mean(annotator_weight)
  
          # examples are annotated by multiple annotators
          else:
              optimal_temp = find_best_temp_scaler(
                  labels_multiannotator, pred_probs
              )
              pred_probs = temp_scale_pred_probs(
                  pred_probs, optimal_temp
              )
  
              multiannotator_info = get_label_quality_multiannotator(
                  labels_multiannotator,
                  pred_probs,
                  return_annotator_stats=False,
                  return_detailed_quality=False,
                  return_weights=True,
              )
  
              quality_of_consensus_labeled = multiannotator_info[
                  "label_quality"
              ]["consensus_quality_score"]
              model_weight = multiannotator_info["model_weight"]
              annotator_weight = multiannotator_info["annotator_weight"]
              avg_annotator_weight = np.mean(annotator_weight)
  
          # compute scores for labeled data
          active_learning_scores = np.full(
              len(labels_multiannotator), np.nan
          )
          for i, annotator_labels in enumerate(labels_multiannotator):
              active_learning_scores[i] = np.average(
                  (quality_of_consensus_labeled[i], 1 / num_classes),
                  weights=(
                      np.sum(
                          annotator_weight[~np.isnan(annotator_labels)]
                      )
                      + model_weight,
                      avg_annotator_weight,
                  ),
              )
  
      # no labeled data provided so do not estimate temperature and model/annotator weights
      elif pred_probs_unlabeled is not None:
          num_classes = get_num_classes(pred_probs=pred_probs_unlabeled)
          optimal_temp = 1
          model_weight = 1
          avg_annotator_weight = 1
          active_learning_scores = np.array([])
  
      else:
          raise ValueError(
              "pred_probs and pred_probs_unlabeled cannot both be None, specify at least one of the two."
          )
  
      # compute scores for unlabeled data
      if pred_probs_unlabeled is not None:
          pred_probs_unlabeled = temp_scale_pred_probs(
              pred_probs_unlabeled, optimal_temp
          )
          quality_of_consensus_unlabeled = np.max(
              pred_probs_unlabeled, axis=1
          )
  
          active_learning_scores_unlabeled = np.average(
              np.stack(
                  [
                      quality_of_consensus_unlabeled,
                      np.full(
                          len(quality_of_consensus_unlabeled),
                          1 / num_classes,
                      ),
                  ]
              ),
              weights=[model_weight, avg_annotator_weight],
              axis=0,
          )
  
      else:
          active_learning_scores_unlabeled = np.array([])
  
      return active_learning_scores, active_learning_scores_unlabeled
  
imports: import warnings
  import numpy
  import pandas
  from typing import List, Dict, Any, Union, Tuple, Optional
  from cleanlab.rank import get_label_quality_scores
  from cleanlab.internal.util import get_num_classes, value_counts
  from cleanlab.internal.constants import CLIPPING_LOWER_BOUND
  from cleanlab.internal.multiannotator_utils import assert_valid_inputs_multiannotator, assert_valid_pred_probs, check_consensus_label_classes, find_best_temp_scaler, temp_scale_pred_probs
label_desc: Use image node_id 3 for calling a global function with example usage: get_active_learning_scores(labels_multiannotator, pred_probs, pred_probs_unlabeled) and returns: active_learning_scores,  active_learning_scores_unlabeled