code: def get_label_quality_scores(
      labels: np.ndarray,
      pred_probs: np.ndarray,
      *,
      method: str = "softmin",
      batch_size: Optional[int] = None,
      n_jobs: Optional[int] = None,
      verbose: bool = True,
      **kwargs,
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Returns a label quality score for each image.
  
      This is a function to compute label quality scores for semantic segmentation datasets,
      where lower scores indicate labels less likely to be correct.
  
      * 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
      ----------
      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 further details.
  
      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 further details.
  
      method: {"softmin", "num_pixel_issues"}, default="softmin"
        Label quality scoring method.
  
        - "softmin" - Calculates the inner product between scores and softmax(1-scores). For efficiency, use instead of "num_pixel_issues".
        - "num_pixel_issues" - Uses the number of pixels with label issues for each image using :py:func:`find_label_issues <cleanlab.segmentation.filter.find_label_issues>`
  
      batch_size :
        Optional size of mini-batches to use for estimating the label issues for 'num_pixel_issues' only, not 'softmin'.
        To maximize efficiency, try to use the largest `batch_size` your memory allows. If not provided, a good default is used.
  
      n_jobs:
        Optional number of processes for multiprocessing (default value = 1). Only used on Linux. For 'num_pixel_issues' only, not 'softmin'
        If `n_jobs=None`, will use either the number of: physical cores if psutil is installed, or logical cores otherwise.
  
      verbose:
        Set to ``False`` to suppress all print statements.
  
      **kwargs:
        * downsample : int,
            Factor to shrink labels and pred_probs by for 'num_pixel_issues' only, not 'softmin' . Default ``16``
            Must be a factor divisible by both the labels and the pred_probs. Larger values of `downsample` produce faster runtimes but potentially less accurate results due to over-compression. Set to 1 to avoid any downsampling.
        * temperature : float,
            Temperature for softmin. Default ``0.1``
  
  
      Returns
      -------
      image_scores:
          Array of shape ``(N, )`` of scores between 0 and 1, one per image in the dataset.
          Lower scores indicate image more likely to contain a label issue.
      pixel_scores:
          Array of shape ``(N,H,W)`` of scores between 0 and 1, one per pixel in the dataset.
      """
      batch_size, n_jobs = _get_valid_optional_params(
          batch_size, n_jobs
      )
      _check_input(labels, pred_probs)
  
      softmin_temperature = kwargs.get("temperature", 0.1)
      downsample_num_pixel_issues = kwargs.get("downsample", 1)
  
      if method == "num_pixel_issues":
          _, K, _, _ = pred_probs.shape
          labels_expanded = labels[:, np.newaxis, :, :]
          mask = (
              np.arange(K)[np.newaxis, :, np.newaxis, np.newaxis]
              == labels_expanded
          )
          # Calculate pixel_scores
          masked_pred_probs = np.where(mask, pred_probs, 0)
          pixel_scores = masked_pred_probs.sum(axis=1)
          scores = find_label_issues(
              labels,
              pred_probs,
              downsample=downsample_num_pixel_issues,
              n_jobs=n_jobs,
              verbose=verbose,
              batch_size=batch_size,
          )
          img_scores = 1 - np.mean(scores, axis=(1, 2))
          return (img_scores, pixel_scores)
  
      if downsample_num_pixel_issues != 1:
          warnings.warn(
              f"image will not downsample for method {method} is only for method: num_pixel_issues"
          )
  
      num_im, num_class, h, w = pred_probs.shape
      image_scores = []
      pixel_scores = []
      if verbose:
          from tqdm.auto import tqdm
  
          pbar = tqdm(
              desc=f"images processed using {method}", total=num_im
          )
      for image in range(num_im):
          image_probs = pred_probs[image][
              labels[image],
              np.arange(h)[:, None],
              np.arange(w),
          ]
          pixel_scores.append(image_probs)
          image_scores.append(
              _get_label_quality_per_image(
                  np.array(image_probs.flatten()),
                  method=method,
                  temperature=softmin_temperature,
              )
          )
          if verbose:
              pbar.update(1)
      return np.array(image_scores), np.array(pixel_scores)
  
file_path: cleanlab/cleanlab/segmentation/rank.py
imports: import numpy
  import warnings
  from typing import Optional, Union, Tuple
  from cleanlab.segmentation.filter import find_label_issues
  from cleanlab.internal.segmentation_utils import _get_valid_optional_params, _check_input
label_desc: Use image node_id 1 for calling a global function with example usage: get_label_quality_scores(labels, pred_probs) and returns: np,  np, img_scores,  pixel_scores