code: def _keep_at_least_n_per_class(
      prune_count_matrix: np.ndarray, n: int, *, frac_noise: float = 1.0
  ) -> np.ndarray:
      """Make sure every class has at least n examples after removing noise.
      Functionally, increase each column, increases the diagonal term #(true_label=k,label=k)
      of prune_count_matrix until it is at least n, distributing the amount
      increased by subtracting uniformly from the rest of the terms in the
      column. When frac_noise = 1.0, return all "confidently" estimated
      noise indices, otherwise this returns frac_noise fraction of all
      the noise counts, with diagonal terms adjusted to ensure column
      totals are preserved.
  
      Parameters
      ----------
      prune_count_matrix : np.ndarray of shape (K, K), K = number of classes
          A counts of mislabeled examples in every class. For this function.
          NOTE prune_count_matrix is transposed relative to confident_joint.
  
      n : int
          Number of examples to make sure are left in each class.
  
      frac_noise : float, default=1.0
        Used to only return the "top" ``frac_noise * num_label_issues``. The choice of which "top"
        label issues to return is dependent on the `filter_by` method used. It works by reducing the
        size of the off-diagonals of the `prune_count_matrix` of given labels and true labels
        proportionally by `frac_noise` prior to estimating label issues with each method.
        When frac_noise=1.0, return all "confident" estimated noise indices (recommended).
  
      Returns
      -------
      prune_count_matrix : np.ndarray of shape (K, K), K = number of classes
          This the same as the confident_joint, but has been transposed and the counts are adjusted.
      """
  
      prune_count_matrix_diagonal = np.diagonal(prune_count_matrix)
  
      # Set diagonal terms less than n, to n.
      new_diagonal = np.maximum(prune_count_matrix_diagonal, n)
  
      # Find how much diagonal terms were increased.
      diff_per_col = new_diagonal - prune_count_matrix_diagonal
  
      # Count non-zero, non-diagonal items per column
      # np.maximum(*, 1) makes this never 0 (we divide by this next)
      num_noise_rates_per_col = np.maximum(
          np.count_nonzero(prune_count_matrix, axis=0) - 1.0,
          1.0,
      )
  
      # Uniformly decrease non-zero noise rates by the same amount
      # that the diagonal items were increased
      new_mat = (
          prune_count_matrix - diff_per_col / num_noise_rates_per_col
      )
  
      # Originally zero noise rates will now be negative, fix them back to zero
      new_mat[new_mat < 0] = 0
  
      # Round diagonal terms (correctly labeled examples)
      np.fill_diagonal(new_mat, new_diagonal)
  
      # Reduce (multiply) all noise rates (non-diagonal) by frac_noise and
      # increase diagonal by the total amount reduced in each column
      # to preserve column counts.
      new_mat = _reduce_prune_counts(new_mat, frac_noise)
  
      # These are counts, so return a matrix of ints.
      return round_preserving_row_totals(new_mat).astype(int)
  
imports: import numpy
  from sklearn.metrics import confusion_matrix
  import multiprocessing
  import sys
  import warnings
  from typing import Any, Dict, Optional, Tuple, List
  from functools import reduce
  import platform
  from cleanlab.count import calibrate_confident_joint, num_label_issues, _reduce_issues
  from cleanlab.rank import order_label_issues, get_label_quality_scores
  import cleanlab.internal.multilabel_scorer
  from cleanlab.internal.validation import assert_valid_inputs
  from cleanlab.internal.util import value_counts_fill_missing_classes, round_preserving_row_totals, get_num_classes
  from cleanlab.internal.multilabel_utils import stack_complement, get_onehot_num_classes, int2onehot
  from cleanlab.typing import LabelLike
  from cleanlab.multilabel_classification.filter import find_multilabel_issues_per_class
label_desc: Use image node_id 3 for calling a global function with example usage: _keep_at_least_n_per_class(prune_count_matrix, n) and returns: round_preserving_row_totals