code: def estimate_py_noise_matrices_and_cv_pred_proba(
      X,
      labels,
      clf=LogReg(multi_class="auto", solver="lbfgs"),
      *,
      cv_n_folds=5,
      thresholds=None,
      converge_latent_estimates=False,
      py_method="cnt",
      seed=None,
      clf_kwargs={},
      validation_func=None,
  ) -> Tuple[
      np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray
  ]:
      """This function computes the out-of-sample predicted
      probability ``P(label=k|x)`` for every example x in `X` using cross
      validation while also computing the confident counts noise
      rates within each cross-validated subset and returning
      the average noise rate across all examples.
  
      This function estimates the `noise_matrix` of shape ``(K, K)``. This is the
      fraction of examples in every class, labeled as every other class. The
      `noise_matrix` is a conditional probability matrix for ``P(label=k_s|true_label=k_y)``.
  
      Under certain conditions, estimates are exact, and in most
      conditions, estimates are within one percent of the actual noise rates.
  
      Parameters
      ----------
      X : np.ndarray
        Input feature matrix of shape ``(N, ...)``, where N is the number of
        examples. The classifier that this instance was initialized with,
        `clf`, must be able to handle data with this shape.
  
      labels : np.ndarray
        A 1D array of shape ``(N,)`` containing class labels for a standard (multi-class) classification dataset.
        Some given labels may be erroneous.
        Elements must be integers in the set 0, 1, ..., K-1, where K is the number of classes.
        All classes must be present in the dataset.
  
      clf : estimator instance, optional
        A classifier implementing the `sklearn estimator API
        <https://scikit-learn.org/stable/developers/develop.html#rolling-your-own-estimator>`_.
  
      cv_n_folds : int, default=5
        The number of cross-validation folds used to compute
        out-of-sample probabilities for each example in `X`.
  
      thresholds : array_like, optional
        An array of shape ``(K, 1)`` or ``(K,)`` of per-class threshold
        probabilities, used to determine the cutoff probability necessary to
        consider an example as a given class label (see `Northcutt et al.,
        2021 <https://jair.org/index.php/jair/article/view/12125>`_, Section
        3.1, Equation 2).
  
        This is for advanced users only. If not specified, these are computed
        for you automatically. If an example has a predicted probability
        greater than this threshold, it is counted as having true_label =
        k. This is not used for pruning/filtering, only for estimating the
        noise rates using confident counts.
  
      converge_latent_estimates : bool, optional
        If ``True``, forces numerical consistency of estimates. Each is estimated
        independently, but they are related mathematically with closed form
        equivalences. This will iteratively make them mathematically consistent.
  
      py_method : {"cnt", "eqn", "marginal", "marginal_ps"}, default="cnt"
        How to compute the latent prior ``p(true_label=k)``. Default is ``"cnt"`` as it often
        works well even when the noise matrices are estimated poorly by using
        the matrix diagonals instead of all the probabilities.
  
      seed : int, optional
        Set the default state of the random number generator used to split
        the cross-validated folds. If ``None``, uses ``np.random`` current random state.
  
      clf_kwargs : dict, optional
        Optional keyword arguments to pass into `clf`'s ``fit()`` method.
  
      validation_func : callable, optional
        Specifies how to map the validation data split in cross-validation as input for ``clf.fit()``.
        For details, see the documentation of :py:meth:`CleanLearning.fit<cleanlab.classification.CleanLearning.fit>`
  
      Returns
      ------
      estimates: tuple
        A tuple of five arrays (py, noise matrix, inverse noise matrix, confident joint, predicted probability matrix).
  
      Note
      ----
      Multi-label classification is not supported in this method.
      """
      (
          confident_joint,
          pred_probs,
      ) = estimate_confident_joint_and_cv_pred_proba(
          X=X,
          labels=labels,
          clf=clf,
          cv_n_folds=cv_n_folds,
          thresholds=thresholds,
          seed=seed,
          clf_kwargs=clf_kwargs,
          validation_func=validation_func,
      )
  
      py, noise_matrix, inv_noise_matrix = estimate_latent(
          confident_joint=confident_joint,
          labels=labels,
          py_method=py_method,
          converge_latent_estimates=converge_latent_estimates,
      )
  
      return (
          py,
          noise_matrix,
          inv_noise_matrix,
          confident_joint,
          pred_probs,
      )
  
imports: from sklearn.linear_model import LogisticRegression
  from sklearn.model_selection import StratifiedKFold
  from sklearn.metrics import confusion_matrix
  import sklearn.base
  import numpy
  import warnings
  from typing import Tuple, Union, Optional
  from cleanlab.typing import LabelLike
  from cleanlab.internal.multilabel_utils import stack_complement, get_onehot_num_classes
  from cleanlab.internal.constants import TINY_VALUE, CONFIDENT_THRESHOLDS_LOWER_BOUND, FLOATING_POINT_COMPARISON
  from cleanlab.internal.util import value_counts_fill_missing_classes, clip_values, clip_noise_rates, round_preserving_row_totals, append_extra_datapoint, train_val_split, get_num_classes, get_unique_classes, is_torch_dataset, is_tensorflow_dataset
  from cleanlab.internal.latent_algebra import compute_inv_noise_matrix, compute_py, compute_noise_matrix_from_inverse
  from cleanlab.internal.validation import assert_valid_inputs, labels_to_array
label_desc: Use image node_id 13 for calling a global function with example usage: estimate_py_noise_matrices_and_cv_pred_proba(X, labels, clf) and returns: py,  noise_matrix,  inv_noise_matrix,  confident_joint,  pred_probs