code: def test_single_instance_with_model(self):
      # initialize/fit explainer
      epochs = 500
      embedding_dim = 4
      layers_config = []
      random_seed = 1
      neighbors = 3
  
      explainer = NearestNeighborContrastiveExplainer(
          model=self.model.predict,
          embedding_dim=embedding_dim,
          layers_config=layers_config,
          neighbors=neighbors,
      )
  
      explainer.fit(
          self.xx_train,
          epochs=epochs,
          numeric_scaling=None,
          random_seed=random_seed,
      )
  
      explanation = explainer.explain_instance(self.xx_test.iloc[10])
  
      # validate explanation structure
      self.assertIn("features", explanation)
      self.assertIn("categorical_features", explanation)
      self.assertIn("query", explanation)
      self.assertIn("neighbors", explanation)
      self.assertIn("distances", explanation)
      self.assertLessEqual(len(explanation["neighbors"]), neighbors)
      self.assertLessEqual(len(explanation["distances"]), neighbors)
  
      prediction = self.model.predict(
          np.asarray([self.xx_test.iloc[10]])
      ).reshape(-1)[0]
      prediction = list(np.array([prediction], dtype=int).reshape(-1))[
          0
      ]
  
      neighbor_prediction = self.model.predict(
          np.asarray([explanation["neighbors"][0]])
      )
      neighbor_prediction = list(
          np.array([neighbor_prediction], dtype=int).reshape(-1)
      )[0]
  
      # validate that the explanation is contrastive
      self.assertNotEqual(prediction, neighbor_prediction)
  
file_path: AIX360/tests/nncontrastive/test_nncontrastive.py
imports: import os
  import warnings
  import unittest
  import numpy
  import pandas
  from sklearn.datasets import load_breast_cancer
  from sklearn.model_selection import train_test_split
  from sklearn.ensemble import RandomForestClassifier
  from aix360.algorithms.nncontrastive import NearestNeighborContrastiveExplainer
label_desc: Use image node_id 3 for calling the TestNearestNeighborContrastiveExplainer obj's underlying member method code with example usage: obj.test_single_instance_with_model() without return types