code: def get_majority_vote_label(
      labels_multiannotator: Union[pd.DataFrame, np.ndarray],
      pred_probs: Optional[np.ndarray] = None,
      verbose: bool = True,
  ) -> np.ndarray:
      """Returns the majority vote label for each example, aggregated from the labels given by multiple annotators.
  
      Parameters
      ----------
      labels_multiannotator : pd.DataFrame or np.ndarray
          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.
          For more details, labels in the same format expected by the `~cleanlab.multiannotator.get_label_quality_multiannotator`.
      pred_probs : np.ndarray, optional
          An array of shape ``(N, K)`` of model-predicted probabilities, ``P(label=k|x)``.
          For details, predicted probabilities in the same format expected by `~cleanlab.multiannotator.get_label_quality_multiannotator`.
      verbose : bool, optional
          Important warnings and other printed statements may be suppressed if ``verbose`` is set to ``False``.
      Returns
      -------
      consensus_label: np.ndarray
          An array of shape ``(N,)`` with the majority vote label aggregated from all annotators.
  
          In the event of majority vote ties, ties are broken in the following order:
          using the model ``pred_probs`` (if provided) and selecting the class with highest predicted probability,
          using the empirical class frequencies and selecting the class with highest frequency,
          using an initial annotator quality score and selecting the class that has been labeled by annotators with higher quality,
          and lastly by random selection.
      """
  
      if isinstance(labels_multiannotator, pd.DataFrame):
          annotator_ids = labels_multiannotator.columns
          labels_multiannotator = (
              labels_multiannotator.replace({pd.NA: np.NaN})
              .astype(float)
              .to_numpy()
          )
      elif isinstance(labels_multiannotator, np.ndarray):
          annotator_ids = None
      else:
          raise ValueError(
              "labels_multiannotator must be either a NumPy array or Pandas DataFrame."
          )
  
      if verbose:
          assert_valid_inputs_multiannotator(
              labels_multiannotator,
              pred_probs,
              annotator_ids=annotator_ids,
          )
  
      if pred_probs is not None:
          num_classes = pred_probs.shape[1]
      else:
          num_classes = int(np.nanmax(labels_multiannotator) + 1)
  
      def get_labels_mode(label_count, num_classes):
          max_count_idx = np.where(
              label_count == np.nanmax(label_count)
          )[0].astype(float)
          return np.pad(
              max_count_idx,
              (0, num_classes - len(max_count_idx)),
              "constant",
              constant_values=np.NaN,
          )
  
      majority_vote_label = np.full(len(labels_multiannotator), np.nan)
      label_count = np.apply_along_axis(
          lambda s: np.bincount(
              s[~np.isnan(s)].astype(int), minlength=num_classes
          ),
          axis=1,
          arr=labels_multiannotator,
      )
      mode_labels_multiannotator = np.apply_along_axis(
          get_labels_mode,
          axis=1,
          arr=label_count,
          num_classes=num_classes,
      )
  
      nontied_idx = []
      tied_idx = dict()
  
      # obtaining consensus using annotator majority vote
      for idx, label_mode in enumerate(mode_labels_multiannotator):
          label_mode = label_mode[~np.isnan(label_mode)].astype(int)
          if len(label_mode) == 1:
              majority_vote_label[idx] = label_mode[0]
              nontied_idx.append(idx)
          else:
              tied_idx[idx] = label_mode
  
      # tiebreak 1: using pred_probs (if provided)
      if pred_probs is not None and len(tied_idx) > 0:
          for idx, label_mode in tied_idx.copy().items():
              max_pred_probs = np.where(
                  pred_probs[idx, label_mode]
                  == np.max(pred_probs[idx, label_mode])
              )[0]
              if len(max_pred_probs) == 1:
                  majority_vote_label[idx] = label_mode[
                      max_pred_probs[0]
                  ]
                  del tied_idx[idx]
              else:
                  tied_idx[idx] = label_mode[max_pred_probs]
  
      # tiebreak 2: using empirical class frequencies
      # current tiebreak will select the minority class (to prevent larger class imbalance)
      if len(tied_idx) > 0:
          class_frequencies = label_count.sum(axis=0)
          for idx, label_mode in tied_idx.copy().items():
              min_frequency = np.where(
                  class_frequencies[label_mode]
                  == np.min(class_frequencies[label_mode])
              )[0]
              if len(min_frequency) == 1:
                  majority_vote_label[idx] = label_mode[
                      min_frequency[0]
                  ]
                  del tied_idx[idx]
              else:
                  tied_idx[idx] = label_mode[min_frequency]
  
      # tiebreak 3: using initial annotator quality scores
      if len(tied_idx) > 0:
          nontied_majority_vote_label = majority_vote_label[nontied_idx]
          nontied_labels_multiannotator = labels_multiannotator[
              nontied_idx
          ]
          annotator_agreement_with_consensus = np.zeros(
              nontied_labels_multiannotator.shape[1]
          )
          for i in range(len(annotator_agreement_with_consensus)):
              labels = nontied_labels_multiannotator[:, i]
              labels_mask = ~np.isnan(labels)
              if np.sum(labels_mask) == 0:
                  annotator_agreement_with_consensus[i] = np.NaN
              else:
                  annotator_agreement_with_consensus[i] = np.mean(
                      labels[labels_mask]
                      == nontied_majority_vote_label[labels_mask]
                  )
  
          # impute average annotator accuracy for any annotator that do not overlap with consensus
          nan_mask = np.isnan(annotator_agreement_with_consensus)
          avg_annotator_agreement = np.mean(
              annotator_agreement_with_consensus[~nan_mask]
          )
          annotator_agreement_with_consensus[
              nan_mask
          ] = avg_annotator_agreement
  
          for idx, label_mode in tied_idx.copy().items():
              label_quality_score = np.array(
                  [
                      np.mean(
                          annotator_agreement_with_consensus[
                              np.where(
                                  labels_multiannotator[idx] == label
                              )[0]
                          ]
                      )
                      for label in label_mode
                  ]
              )
              max_score = np.where(
                  label_quality_score == label_quality_score.max()
              )[0]
              if len(max_score) == 1:
                  majority_vote_label[idx] = label_mode[max_score[0]]
                  del tied_idx[idx]
              else:
                  tied_idx[idx] = label_mode[max_score]
  
      # if still tied, break by random selection
      if len(tied_idx) > 0:
          warnings.warn(
              f"breaking ties of examples {list(tied_idx.keys())} by random selection, you may want to set seed for reproducability"
          )
          for idx, label_mode in tied_idx.items():
              majority_vote_label[idx] = np.random.choice(label_mode)
  
      if verbose:
          # check if any classes no longer appear in the set of consensus labels
          check_consensus_label_classes(
              labels_multiannotator=labels_multiannotator,
              consensus_label=majority_vote_label,
              consensus_method="majority_vote",
          )
  
      return majority_vote_label.astype(int)
  
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 5 for calling a global function with example usage: get_majority_vote_label(labels_multiannotator, pred_probs, verbose) and returns: majority_vote_label, np