class_docstr: Provides scores to detect Out Of Distribution (OOD) examples that are outliers in a dataset.
  
  Each example's OOD score lies in [0,1] with smaller values indicating examples that are less typical under the data distribution.
  OOD scores may be estimated from either: numeric feature embeddings or predicted probabilities from a trained classifier.
  
  To get indices of examples that are the most severe outliers, call `~cleanlab.rank.find_top_issues` function on the returned OOD scores.
  
  Parameters
  ----------
  params : dict, default = {}
   Optional keyword arguments to control how this estimator is fit. Effect of arguments passed in depends on if
   `OutOfDistribution` estimator will rely on `features` or `pred_probs`. These are stored as an instance attribute `self.params`.
  
   If `features` is passed in during ``fit()``, `params` could contain following keys:
     *  knn: sklearn.neighbors.NearestNeighbors, default = None
           Instantiated ``NearestNeighbors`` object that's been fitted on a dataset in the same feature space.
           Note that the distance metric and `n_neighbors` is specified when instantiating this class.
           You can also pass in a subclass of ``sklearn.neighbors.NearestNeighbors`` which allows you to use faster
           approximate neighbor libraries as long as you wrap them behind the same sklearn API.
           If you specify ``knn`` here, there is no need to later call ``fit()`` before calling ``score()``.
           If ``knn = None``, then by default: ``knn = sklearn.neighbors.NearestNeighbors(n_neighbors=k, metric=dist_metric).fit(features)``
           where ``dist_metric == "cosine"`` if ``dim(features) > 3`` or ``dist_metric == "euclidean"`` otherwise.
           See: https://scikit-learn.org/stable/modules/neighbors.html
     *  k : int, default=None
           Optional number of neighbors to use when calculating outlier score (average distance to neighbors).
           If `k` is not provided, then by default ``k = knn.n_neighbors`` or ``k = 10`` if ``knn is None``.
           If an existing ``knn`` object is provided, you can still specify that outlier scores should use
           a different value of `k` than originally used in the ``knn``,
           as long as your specified value of `k` is smaller than the value originally used in ``knn``.
     *  t : int, default=1
           Optional hyperparameter only for advanced users.
           Controls transformation of distances between examples into similarity scores that lie in [0,1].
           The transformation applied to distances `x` is ``exp(-x*t)``.
           If you find your scores are all too close to 1, consider increasing `t`,
           although the relative scores of examples will still have the same ranking across the dataset.
  
   If `pred_probs` is passed in during ``fit()``, `params` could contain following keys:
     *  confident_thresholds: np.ndarray, default = None
           An array of shape ``(K, )`` where K is the number of classes.
           Confident threshold for a class j is the expected (average) "self-confidence" for that class.
           If you specify `confident_thresholds` here, there is no need to later call ``fit()`` before calling ``score()``.
     *  adjust_pred_probs : bool, True
           If True, account for class imbalance by adjusting predicted probabilities
           via subtraction of class confident thresholds and renormalization.
           If False, you do not have to pass in `labels` later to fit this OOD estimator.
           See `Northcutt et al., 2021 <https://jair.org/index.php/jair/article/view/12125>`_.
     *  method : {"entropy", "least_confidence"}, default="entropy"
           Method to use when computing outlier scores based on `pred_probs`.
           Letting length-K vector ``P = pred_probs[i]`` denote the given predicted class-probabilities
           for the i-th example in dataset, its outlier score can either be:
  
           - ``'entropy'``: ``1 - sum_{j} P[j] * log(P[j]) / log(K)``
           - ``'least_confidence'``: ``max(P)`` (equivalent to Maximum Softmax Probability method from the OOD detection literature)
           - ``gen``: Generalized ENtropy score from the paper of Liu, Lochman, and Zach (https://openaccess.thecvf.com/content/CVPR2023/papers/Liu_GEN_Pushing_the_Limits_of_Softmax-Based_Out-of-Distribution_Detection_CVPR_2023_paper.pdf)
docstr: Use fitted estimator and passed in `features` or `pred_probs` to calculate out-of-distribution scores for a dataset.
  
  Score for each example corresponds to the likelihood this example stems from the same distribution as the dataset previously specified in ``fit()`` (i.e. is not an outlier).
  
  If `features` are passed, returns OOD score for each example based on its feature values.
  If `pred_probs` are passed, returns OOD score for each example based on classifier's probabilistic predictions.
  You may have to previously call ``fit()`` or call ``fit_score()`` instead.
  
  Parameters
  ----------
  features : np.ndarray, optional
    Feature array of shape ``(N, M)``, where N is the number of examples and M is the number of features used to represent each example.
    For details, see `features` in `~cleanlab.outlier.OutOfDistribution.fit` function.
  
  pred_probs : np.ndarray, optional
    An array of shape ``(N, K)``  of predicted class probabilities output by a trained classifier.
    For details, see `pred_probs` in `~cleanlab.outlier.OutOfDistribution.fit` function.
  
  Returns
  -------
  scores : np.ndarray
    Scores lie in [0,1] with smaller values indicating examples that are less typical under the dataset distribution
    (values near 0 indicate outliers).
  
    If `features` are passed, `ood_features_scores` are returned.
    The score is based on the average distance between the example and its K nearest neighbors in the dataset
    (in feature space).
  
    If `pred_probs` are passed, `ood_predictions_scores` are returned.
    The score is based on the uncertainty in the classifier's predicted probabilities.
docstr_tok: ["Use","fitted","estimator","and","passed","in","`","features","`","or","`","pred_probs","`","to","calculate","out-of-distribution","scores","for","a","dataset",".","Score","for","each","example","corresponds","to","the","likelihood","this","example","stems","from","the","same","distribution","as","the","dataset","previously","specified","in","``","fit","(",")","``","(","i.e",".","is","not","an","outlier",")",".","If","`","features","`","are","passed",",","returns","OOD","score","for","each","example","based","on","its","feature","values",".","If","`","pred_probs","`","are","passed",",","returns","OOD","score","for","each","example","based","on","classifier","'s","probabilistic","predictions",".","You","may","have","to","previously","call","``","fit","(",")","``","or","call","``","fit_score","(",")","``","instead",".","Parameters","--","--","--","--","--","features",":","np.ndarray",",","optional","Feature","array","of","shape","``","(","N",",","M",")","``",",","where","N","is","the","number","of","examples","and","M","is","the","number","of","features","used","to","represent","each","example",".","For","details",",","see","`","features","`","in","`","~cleanlab.outlier.OutOfDistribution.fit","`","function",".","pred_probs",":","np.ndarray",",","optional","An","array","of","shape","``","(","N",",","K",")","``","of","predicted","class","probabilities","output","by","a","trained","classifier",".","For","details",",","see","`","pred_probs","`","in","`","~cleanlab.outlier.OutOfDistribution.fit","`","function",".","Returns","--","--","--","-","scores",":","np.ndarray","Scores","lie","in","[","0,1","]","with","smaller","values","indicating","examples","that","are","less","typical","under","the","dataset","distribution","(","values","near","0","indicate","outliers",")",".","If","`","features","`","are","passed",",","`","ood_features_scores","`","are","returned",".","The","score","is","based","on","the","average","distance","between","the","example","and","its","K","nearest","neighbors","in","the","dataset","(","in","feature","space",")",".","If","`","pred_probs","`","are","passed",",","`","ood_predictions_scores","`","are","returned",".","The","score","is","based","on","the","uncertainty","in","the","classifier","'s","predicted","probabilities","."]
code: def score(
      self,
      *,
      features: Optional[np.ndarray] = None,
      pred_probs: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      """
      Use fitted estimator and passed in `features` or `pred_probs` to calculate out-of-distribution scores for a dataset.
  
      Score for each example corresponds to the likelihood this example stems from the same distribution as the dataset previously specified in ``fit()`` (i.e. is not an outlier).
  
      If `features` are passed, returns OOD score for each example based on its feature values.
      If `pred_probs` are passed, returns OOD score for each example based on classifier's probabilistic predictions.
      You may have to previously call ``fit()`` or call ``fit_score()`` instead.
  
      Parameters
      ----------
      features : np.ndarray, optional
        Feature array of shape ``(N, M)``, where N is the number of examples and M is the number of features used to represent each example.
        For details, see `features` in `~cleanlab.outlier.OutOfDistribution.fit` function.
  
      pred_probs : np.ndarray, optional
        An array of shape ``(N, K)``  of predicted class probabilities output by a trained classifier.
        For details, see `pred_probs` in `~cleanlab.outlier.OutOfDistribution.fit` function.
  
      Returns
      -------
      scores : np.ndarray
        Scores lie in [0,1] with smaller values indicating examples that are less typical under the dataset distribution
        (values near 0 indicate outliers).
  
        If `features` are passed, `ood_features_scores` are returned.
        The score is based on the average distance between the example and its K nearest neighbors in the dataset
        (in feature space).
  
        If `pred_probs` are passed, `ood_predictions_scores` are returned.
        The score is based on the uncertainty in the classifier's predicted probabilities.
      """
      self._assert_valid_inputs(features, pred_probs)
  
      if features is not None:
          if self.params["knn"] is None:
              raise ValueError(
                  "OOD estimator needs to be fit on features first. Call `fit()` or `fit_scores()` before this function."
              )
          scores, _ = _get_ood_features_scores(
              features, **self._get_params(self.OUTLIER_PARAMS)
          )
  
      if pred_probs is not None:
          if (
              self.params["confident_thresholds"] is None
              and self.params["adjust_pred_probs"]
          ):
              raise ValueError(
                  "OOD estimator needs to be fit on pred_probs first since params['adjust_pred_probs']=True. Call `fit()` or `fit_scores()` before this function."
              )
          scores, _ = _get_ood_predictions_scores(
              pred_probs, **self._get_params(self.OOD_PARAMS)
          )
  
      return scores
  
imports: import warnings
  import numpy
  from cleanlab.count import get_confident_thresholds
  from sklearn.neighbors import NearestNeighbors
  from sklearn.exceptions import NotFittedError
  from typing import Optional, Union, Tuple, Dict, cast
  from cleanlab.internal.label_quality_utils import _subtract_confident_thresholds, get_normalized_entropy
  from cleanlab.internal.numerics import softmax
  from cleanlab.internal.outlier import transform_distances_to_scores
  from cleanlab.internal.validation import assert_valid_inputs, labels_to_array
  from cleanlab.typing import LabelLike
label_desc: Use image node_id 4 for calling the OutOfDistribution obj's underlying member method code with example usage: obj.score() and returns: scores