code: def common_label_issues(
      issues: np.ndarray,
      labels: np.ndarray,
      pred_probs: np.ndarray,
      *,
      class_names: Optional[List[str]] = None,
      exclude: Optional[List[int]] = None,
      top: Optional[int] = None,
      verbose: bool = True,
  ) -> pd.DataFrame:
      """
      Display the frequency of which label are swapped in the dataset.
  
      These may correspond to pixels that are ambiguous or systematically misunderstood by the data annotators.
  
      * N - Number of images in the dataset
      * K - Number of classes in the dataset
      * H - Height of each image
      * W - Width of each image
  
      Parameters
      ----------
      issues:
        Boolean **mask** for the entire dataset
        where ``True`` represents a pixel label issue and ``False`` represents an example that is
        accurately labeled.
  
        Same format as output by :py:func:`segmentation.filter.find_label_issues <cleanlab.segmentation.filter.find_label_issues>`
        or :py:func:`segmentation.rank.issues_from_scores <cleanlab.segmentation.rank.issues_from_scores>`.
  
      labels:
        A discrete array of noisy labels for a segmantic segmentation dataset, in the shape ``(N,H,W,)``.
        where each pixel must be integer in 0, 1, ..., K-1.
        Refer to documentation for this argument in :py:func:`find_label_issues <cleanlab.segmentation.filter.find_label_issues>` for more information.
  
      pred_probs:
        An array of shape ``(N,K,H,W,)`` of model-predicted class probabilities.
        Refer to documentation for this argument in :py:func:`find_label_issues <cleanlab.segmentation.filter.find_label_issues>` for more information.
  
        Tip
        ---
        If your labels are one hot encoded you can `np.argmax(labels_one_hot, axis=1)` assuming that `labels_one_hot` is of dimension (N,K,H,W)
        before entering in the function
  
      class_names:
        Optional length K list of names of each class, such that `class_names[i]` is the string name of the class corresponding to `labels` with value `i`.
        If `class_names` is provided, display these string names for predicted and given labels, otherwise display the integer index of classes.
  
      exclude:
        Optional list of label classes that can be ignored in the errors, each element must be in 0, 1, ..., K-1.
  
      top:
        Optional maximum number of tokens to print information for. If not provided, a good default is used.
  
      verbose:
        Set to ``False`` to suppress all print statements.
  
      Returns
      -------
      issues_df:
        DataFrame with columns ``['given_label', 'predicted_label', 'num_label_issues']``
        where each row contains information about a particular given/predicted label swap.
        Rows are ordered by the number of label issues inferred to exhibit this type of label swap.
      """
      try:
          N, K, H, W = pred_probs.shape
      except:
          raise ValueError("pred_probs must be of shape (N, K, H, W)")
  
      assert labels.shape == (
          N,
          H,
          W,
      ), "labels must be of shape (N, H, W)"
  
      class_names, exclude, top = _get_summary_optional_params(
          class_names, exclude, top
      )
      # Find issues by pixel coordinates
      issue_coords = np.column_stack(np.where(issues))
  
      # Count issues per class (given label)
      count: Dict[int, Any] = {}
      for i, j, k in tqdm(issue_coords):
          label = labels[i, j, k]
          pred = pred_probs[i, :, j, k].argmax()
          if label not in count:
              count[label] = np.zeros(K, dtype=int)
          if pred not in exclude:
              count[label][pred] += 1
  
      # Prepare output DataFrame
      if class_names is None:
          class_names = [str(i) for i in range(K)]
  
      info = []
      for given_label, class_name in enumerate(class_names):
          if given_label in count:
              for pred_label, num_issues in enumerate(
                  count[given_label]
              ):
                  if num_issues > 0:
                      info.append(
                          [
                              class_name,
                              class_names[pred_label],
                              num_issues,
                          ]
                      )
  
      info = sorted(info, key=lambda x: x[2], reverse=True)[:top]
      issues_df = pd.DataFrame(
          info,
          columns=[
              "given_label",
              "predicted_label",
              "num_pixel_issues",
          ],
      )
  
      if verbose:
          for idx, row in issues_df.iterrows():
              print(
                  f"Class '{row['given_label']}' is potentially mislabeled as class for '{row['predicted_label']}' "
                  f"{row['num_pixel_issues']} pixels in the dataset"
              )
  
      return issues_df
  
file_path: cleanlab/cleanlab/segmentation/summary.py
imports: from typing import Any, Dict, List, Optional
  import numpy
  import pandas
  from tqdm import tqdm
  from cleanlab.internal.segmentation_utils import _get_summary_optional_params
label_desc: Use image node_id 2 for calling a global function with example usage: common_label_issues(issues, labels, pred_probs) and returns: issues_df