class_docstr: Manages issues related to non-iid data distributions.
  
  Parameters
  ----------
  datalab :
      The Datalab instance that this issue manager searches for issues in.
  
  metric :
      The distance metric used to compute the KNN graph of the examples in the dataset.
      If set to `None`, the metric will be automatically selected based on the dimensionality
      of the features used to represent the examples in the dataset.
  
  k :
      The number of nearest neighbors to consider when computing the KNN graph of the examples.
  
  num_permutations :
      The number of trials to run when performing permutation testing to determine whether
      the distribution of index-distances between neighbors in the dataset is IID or not.
  
  Note
  ----
  This class will only flag a single example as an issue if the dataset is considered non-IID. This type of issue
  is more relevant to the entire dataset as a whole, rather than to individual examples.
class_docstr_tok: ["Manages","issues","related","to","non-iid","data","distributions",".","Parameters","--","--","--","--","--","datalab",":","The","Datalab","instance","that","this","issue","manager","searches","for","issues","in",".","metric",":","The","distance","metric","used","to","compute","the","KNN","graph","of","the","examples","in","the","dataset",".","If","set","to","`","None","`",",","the","metric","will","be","automatically","selected","based","on","the","dimensionality","of","the","features","used","to","represent","the","examples","in","the","dataset",".","k",":","The","number","of","nearest","neighbors","to","consider","when","computing","the","KNN","graph","of","the","examples",".","num_permutations",":","The","number","of","trials","to","run","when","performing","permutation","testing","to","determine","whether","the","distribution","of","index-distances","between","neighbors","in","the","dataset","is","IID","or","not",".","Note","--","--","This","class","will","only","flag","a","single","example","as","an","issue","if","the","dataset","is","considered","non-IID",".","This","type","of","issue","is","more","relevant","to","the","entire","dataset","as","a","whole",",","rather","than","to","individual","examples","."]
docstr: Determines the feature array to be used for the non-IID check. Prioritizing the original features array over pred_probs.
  
  Parameters
  ----------
  features :
      Original feature array or None.
  
  pred_probs :
      Predicted probabilities array or None.
  
  Returns
  -------
  features_to_use :
      Either the original feature array or the predicted probabilities array,
      intended to be used for the non-IID check.
  
  Raises
  ------
  ValueError :
      If both `features` and `pred_probs` are None.
docstr_tok: ["Determines","the","feature","array","to","be","used","for","the","non-IID","check",".","Prioritizing","the","original","features","array","over","pred_probs",".","Parameters","--","--","--","--","--","features",":","Original","feature","array","or","None",".","pred_probs",":","Predicted","probabilities","array","or","None",".","Returns","--","--","--","-","features_to_use",":","Either","the","original","feature","array","or","the","predicted","probabilities","array",",","intended","to","be","used","for","the","non-IID","check",".","Raises","--","--","--","ValueError",":","If","both","`","features","`","and","`","pred_probs","`","are","None","."]
code: def _determine_features(
      features: Optional[npt.NDArray],
      pred_probs: Optional[np.ndarray],
  ) -> npt.NDArray:
      """
      Determines the feature array to be used for the non-IID check. Prioritizing the original features array over pred_probs.
  
      Parameters
      ----------
      features :
          Original feature array or None.
  
      pred_probs :
          Predicted probabilities array or None.
  
      Returns
      -------
      features_to_use :
          Either the original feature array or the predicted probabilities array,
          intended to be used for the non-IID check.
  
      Raises
      ------
      ValueError :
          If both `features` and `pred_probs` are None.
      """
      if features is not None:
          return features
  
      if pred_probs is not None:
          return pred_probs
  
      raise ValueError(
          "If a knn_graph is not provided, either 'features' or 'pred_probs' must be provided to fit a new knn."
      )
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union, cast
  import warnings
  import itertools
  from scipy.stats import gaussian_kde
  import numpy
  import pandas
  from scipy.sparse import csr_matrix
  from sklearn.neighbors import NearestNeighbors
  from sklearn.exceptions import NotFittedError
  from sklearn.utils.validation import check_is_fitted
  from cleanlab.datalab.internal.issue_manager import IssueManager
label_desc: Use image node_id 2 for calling the NonIIDIssueManager obj's underlying member method code with example usage: obj._determine_features(features, pred_probs) and returns: features, pred_probs