code: def _get_consensus_stats(
      labels_multiannotator: np.ndarray,
      pred_probs: np.ndarray,
      num_annotations: np.ndarray,
      consensus_label: np.ndarray,
      quality_method: str = "crowdlab",
      verbose: bool = True,
      ensemble: bool = False,
      label_quality_score_kwargs: dict = {},
  ) -> tuple:
      """Returns a tuple containing the consensus labels, annotator agreement scores, and quality of consensus
  
      Parameters
      ----------
      labels_multiannotator : np.ndarray
          2D numpy 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.
          For more details, labels in the same format expected by the `~cleanlab.multiannotator.get_label_quality_multiannotator`.
      pred_probs : np.ndarray
          An array of shape ``(N, K)`` of model-predicted probabilities, ``P(label=k|x)``.
          For details, predicted probabilities in the same format expected by the `~cleanlab.multiannotator.get_label_quality_multiannotator`.
      num_annotations : np.ndarray
          An array of shape ``(N,)`` with the number of annotators that have labeled each example.
      consensus_label : np.ndarray
          An array of shape ``(N,)`` with the consensus labels aggregated from all annotators.
      quality_method : str, default = "crowdlab" (Options: ["crowdlab", "agreement"])
          Specifies the method used to calculate the quality of the consensus label.
          For valid quality methods, view `~cleanlab.multiannotator.get_label_quality_multiannotator`
      label_quality_score_kwargs : dict, optional
          Keyword arguments to pass into ``get_label_quality_scores()``.
      verbose : bool, default = True
          Certain warnings and notes will be printed if ``verbose`` is set to ``True``.
      ensemble : bool, default = False
          Boolean flag to indicate whether the pred_probs passed are from ensemble models.
  
      Returns
      ------
      stats : tuple
          A tuple of (consensus_label, annotator_agreement, consensus_quality_score, post_pred_probs).
      """
  
      # compute the fraction of annotator agreeing with the consensus labels
      annotator_agreement = _get_annotator_agreement_with_consensus(
          labels_multiannotator=labels_multiannotator,
          consensus_label=consensus_label,
      )
  
      # compute posterior predicted probabilites
      if ensemble:
          (
              post_pred_probs,
              model_weight,
              annotator_weight,
          ) = _get_post_pred_probs_and_weights_ensemble(
              labels_multiannotator=labels_multiannotator,
              consensus_label=consensus_label,
              prior_pred_probs=pred_probs,
              num_annotations=num_annotations,
              annotator_agreement=annotator_agreement,
              quality_method=quality_method,
              verbose=verbose,
          )
      else:
          (
              post_pred_probs,
              model_weight,
              annotator_weight,
          ) = _get_post_pred_probs_and_weights(
              labels_multiannotator=labels_multiannotator,
              consensus_label=consensus_label,
              prior_pred_probs=pred_probs,
              num_annotations=num_annotations,
              annotator_agreement=annotator_agreement,
              quality_method=quality_method,
              verbose=verbose,
          )
  
      # compute quality of the consensus labels
      consensus_quality_score = _get_consensus_quality_score(
          consensus_label=consensus_label,
          pred_probs=post_pred_probs,
          num_annotations=num_annotations,
          annotator_agreement=annotator_agreement,
          quality_method=quality_method,
          label_quality_score_kwargs=label_quality_score_kwargs,
      )
  
      return (
          annotator_agreement,
          consensus_quality_score,
          post_pred_probs,
          model_weight,
          annotator_weight,
      )
  
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 7 for calling a global function with example usage: _get_consensus_stats(labels_multiannotator, pred_probs, num_annotations, consensus_label, quality_method, verbose, ensemble, label_quality_score_kwargs) and returns: annotator_agreement,  consensus_quality_score,  post_pred_probs,  model_weight,  annotator_weight