code: def test_class_public_func():
      features = data["X_test"]
      pred_probs = data["pred_probs"]
      labels = data["true_labels_test"]
  
      # Fit Logistic Regression model on X_train and estimate train pred_probs
      logreg = LogReg(multi_class="auto", solver="lbfgs")
      logreg.fit(data["X_train"], data["true_labels_train"])
      train_pred_probs = logreg.predict_proba(data["X_train"])
  
      # Get knn and confident_thresholds and pass them into OOD object initialization for testing already fitted logic
      knn = NearestNeighbors(n_neighbors=7).fit(data["X_train"])
      confident_thresholds = get_confident_thresholds(
          pred_probs=train_pred_probs, labels=data["true_labels_train"]
      )
      OOD_outlier_already_fit = OutOfDistribution(params={"knn": knn})
      OOD_ood_already_fit = OutOfDistribution(
          params={"confident_thresholds": confident_thresholds}
      )
  
      #### TESTING INITIALIZATION
      # TESTING knn and confident_thresholds passed during initialization correctly
      assert OOD_outlier_already_fit.params["knn"].n_neighbors == 7
      assert (
          OOD_ood_already_fit.params["confident_thresholds"]
          == confident_thresholds
      ).all()
  
      #### TESTING FIT:
      # Test fitting OOD object without labels and adjust_pred_probs=False
      OOD_ood = OutOfDistribution(params={"adjust_pred_probs": False})
      OOD_ood.fit(pred_probs=data["pred_probs"], labels=None)  # Warning
      assert OOD_ood.params["adjust_pred_probs"] is False
      OOD_ood.score(
          pred_probs=pred_probs
      )  # This should be ok without passing in labels since we are not adjusting
  
      # Testing regular fit
      OOD_ood = OutOfDistribution()
      print(OOD_ood.params)
      OOD_ood.fit(pred_probs=pred_probs, labels=labels)
      print(OOD_ood.params)
      OOD_outlier = OutOfDistribution()
      OOD_outlier.fit(features=features)
      print(OOD_outlier.params)
      assert (
          OOD_ood.params["confident_thresholds"] is not None
          and OOD_ood.params["knn"] is None
      )
      assert (
          OOD_outlier.params["knn"] is not None
          and OOD_outlier.params["confident_thresholds"] is None
      )
      assert (
          OOD_ood.params is not None and OOD_outlier.params is not None
      )
  
      # Testing calling fit on already fitted function (should not overwrite but warn)
      OOD_outlier_already_fit.fit(features=features)  # Warning
      assert (
          OOD_outlier_already_fit.params["knn"].n_neighbors == 7
      )  # Assert not overwritten
      OOD_ood_already_fit.fit(
          pred_probs=pred_probs, labels=labels
      )  # Warning
      assert (
          OOD_ood_already_fit.params["confident_thresholds"]
          == confident_thresholds
      ).all()  # Assert not overwritten
  
      # Testing fit uses correct metrics given feature dimensionality
      X_small = np.random.rand(20, 3)
      OOD_euclidean = OutOfDistribution()
      OOD_euclidean.fit(features=X_small)
      assert OOD_euclidean.params["knn"].metric == "euclidean"
      X_small_with_ood = np.vstack([X_small, [999999.0] * 3])
      euclidean_score = OOD_euclidean.score(features=X_small_with_ood)
      assert (np.max(euclidean_score) <= 1) and (
          np.min(euclidean_score) >= 0
      )
      assert np.argmin(euclidean_score) == (
          euclidean_score.shape[0] - 1
      )
  
      # Re-run tests with high dimensional dataset
      X_large = np.hstack(
          [np.zeros((200, 400)), np.random.rand(200, 1)]
      )
      OOD_cosine = OutOfDistribution()
      OOD_cosine.fit(features=X_large)
      assert OOD_cosine.params["knn"].metric == "cosine"
      X_large_with_ood = np.vstack([X_large, [999999.0] * 401])
      cosine_score = OOD_cosine.score(features=X_large_with_ood)
      assert (np.max(cosine_score) <= 1) and (np.min(cosine_score) >= 0)
      assert np.argmin(cosine_score) == (cosine_score.shape[0] - 1)
  
      #### TESTING SCORE
      ood_score = OOD_ood.score(pred_probs=pred_probs)
      outlier_score = OOD_outlier.score(features=features)
  
      assert ood_score is not None and outlier_score is not None
      assert np.sum(ood_score) != np.sum(outlier_score)
  
      #### TESTING FIT SCORE
      OOD_ood_fs = OutOfDistribution()
      ood_score_fs = OOD_ood_fs.fit_score(
          pred_probs=pred_probs, labels=labels
      )
      OOD_outlier_fs = OutOfDistribution()
      outlier_score_fs = OOD_outlier_fs.fit_score(features=features)
  
      assert (
          OOD_ood_fs.params["confident_thresholds"] is not None
          and OOD_ood_fs.params["knn"] is None
      )
      assert (
          OOD_ood_fs.params["confident_thresholds"]
          == OOD_ood.params["confident_thresholds"]
      ).all()
  
      assert (
          OOD_outlier.params["knn"] is not None
          and OOD_outlier.params["confident_thresholds"] is None
      )
      assert ood_score_fs is not None and outlier_score_fs is not None
  
      assert (
          np.sum(outlier_score_fs) - np.sum(outlier_score) < 1
      )  # scores are similar
      assert (
          np.sum(ood_score_fs) - np.sum(ood_score) < 1
      )  # scores are similar
  
      # Testing calling fit_score on already fitted function
      score_outlier_fs = OOD_outlier_already_fit.fit_score(
          features=features
      )  # Warning
      assert OOD_outlier_already_fit.params["knn"].n_neighbors == 7
      score_ood_fs = OOD_ood_already_fit.fit_score(
          pred_probs=pred_probs, labels=labels
      )  # Warning
      assert (
          OOD_ood_already_fit.params["confident_thresholds"]
          == confident_thresholds
      ).all()
      assert (
          score_outlier_fs is not None and score_ood_fs is not None
      )  # Assert scores still calculated
  
      # Testing calling fit_score repeatedly on already fitted function does not fit it more, just scores same as before
      score_outlier_fs1 = OOD_outlier_already_fit.fit_score(
          features=features
      )  # Warning
      score_ood_fs1 = OOD_ood_already_fit.fit_score(
          pred_probs=pred_probs, labels=labels
      )  # Warning
      assert (score_outlier_fs == score_outlier_fs1).all() and (
          score_ood_fs1 == score_ood_fs
      ).all()
  
      # Testing scores calculated during already fitted fit_score identical to scores calculated during score.
      score_outlier_s = OOD_outlier_already_fit.score(features=features)
      score_ood_s = OOD_ood_already_fit.score(pred_probs=pred_probs)
      assert (score_outlier_fs == score_outlier_s).all() and (
          score_ood_fs == score_ood_s
      ).all()
  
imports: import numpy
  import pandas
  import pytest
  from cleanlab.benchmarking.noise_generation import generate_noise_matrix_from_trace
  from cleanlab.benchmarking.noise_generation import generate_noisy_labels
  from cleanlab import count, outlier
  from cleanlab.count import get_confident_thresholds
  from cleanlab.outlier import OutOfDistribution
  from cleanlab.internal.label_quality_utils import get_normalized_entropy
  from sklearn.neighbors import NearestNeighbors
  from sklearn.linear_model import LogisticRegression
label_desc: Use image node_id 5 for calling a global function with example usage: test_class_public_func() without return types