code: def rank_classes_by_multilabel_quality(
      labels=None,
      pred_probs=None,
      *,
      class_names=None,
      joint=None,
      confident_joint=None,
  ) -> pd.DataFrame:
      """
      Returns a DataFrame with three overall label quality scores per class for a multi-label dataset.
  
      These numbers summarize all examples annotated with the class (details listed below under the Returns parameter).
      By default, classes are ordered by "Label Quality Score", so the most problematic classes are reported first in the DataFrame.
  
      Score values are unnormalized and may be very small. What matters is their relative ranking across the classes.
  
      **Parameters**:
  
      For information about the arguments to this method, see the documentation of
      `~cleanlab.multilabel_classification.dataset.common_multilabel_issues`.
  
      Returns
      -------
      overall_label_quality : pd.DataFrame
          Pandas DataFrame with one row per class and columns: "Class Index", "Label Issues",
          "Inverse Label Issues", "Label Issues", "Inverse Label Noise", "Label Quality Score".
          Some entries are overall quality scores between 0 and 1, summarizing how good overall the labels
          appear to be for that class (lower values indicate more erroneous labels).
          Other entries are estimated counts of annotation errors related to this class.
  
          Here is what each column represents:
              - *Class Name*: The name of the class if class_names is provided.
              - *Class Index*: The index of the class in 0, 1, ..., K-1.
              - *Label Issues*: Estimated number of examples in the dataset that are labeled as belonging to class k but actually should not belong to this class.
              - *Inverse Label Issues*: Estimated number of examples in the dataset that should actually be labeled as class k but did not receive this label.
              - *Label Noise*: Estimated proportion of examples in the dataset that are labeled as class k but should not be. For each class k: this is computed by dividing the number of examples with "Label Issues" that were labeled as class k by the total number of examples labeled as class k.
              - *Inverse Label Noise*: Estimated proportion of examples in the dataset that should actually be labeled as class k but did not receive this label.
              - *Label Quality Score*: Estimated proportion of examples labeled as class k that have been labeled correctly, i.e. ``1 - label_noise``.
  
          By default, the DataFrame is ordered by "Label Quality Score" (in ascending order), so the classes with the most label issues appear first.
      """
  
      issues_df = common_multilabel_issues(
          labels=labels,
          pred_probs=pred_probs,
          class_names=class_names,
          confident_joint=joint,
      )
      issues_dict = defaultdict(defaultdict)  # type: Dict[str, Any]
      num_examples = _get_num_examples_multilabel(
          labels=labels, confident_joint=confident_joint
      )
      return_columns = [
          "Class Name",
          "Class Index",
          "Label Issues",
          "Inverse Label Issues",
          "Label Noise",
          "Inverse Label Noise",
          "Label Quality Score",
      ]
      if class_names is None:
          return_columns = return_columns[1:]
      for class_num, row in issues_df.iterrows():
          if row["In Given Label"]:
              if class_names is not None:
                  issues_dict[row["Class Index"]]["Class Name"] = row[
                      "Class Name"
                  ]
              issues_dict[row["Class Index"]]["Label Issues"] = int(
                  row["Issue Probability"] * num_examples
              )
              issues_dict[row["Class Index"]]["Label Noise"] = row[
                  "Issue Probability"
              ]
              issues_dict[row["Class Index"]]["Label Quality Score"] = (
                  1 - issues_dict[row["Class Index"]]["Label Noise"]
              )
          else:
              if class_names is not None:
                  issues_dict[row["Class Index"]]["Class Name"] = row[
                      "Class Name"
                  ]
              issues_dict[row["Class Index"]][
                  "Inverse Label Issues"
              ] = int(row["Issue Probability"] * num_examples)
              issues_dict[row["Class Index"]][
                  "Inverse Label Noise"
              ] = row["Issue Probability"]
  
      issues_df_dict = defaultdict(list)
      for i in issues_dict:
          issues_df_dict["Class Index"].append(i)
          for j in issues_dict[i]:
              issues_df_dict[j].append(issues_dict[i][j])
      return (
          pd.DataFrame.from_dict(issues_df_dict)
          .sort_values(by="Label Quality Score", ascending=True)
          .reset_index(drop=True)
      )[return_columns]
  
file_path: cleanlab/cleanlab/multilabel_classification/dataset.py
imports: import pandas
  import numpy
  from typing import Optional, cast, Dict, Any
  from cleanlab.multilabel_classification.filter import find_multilabel_issues_per_class, find_label_issues
  from cleanlab.internal.multilabel_utils import get_onehot_num_classes
  from collections import defaultdict
label_desc: Use image node_id 2 for calling a global function with example usage: rank_classes_by_multilabel_quality(labels, pred_probs) and returns: pd