code: def test_single_instance_only(self):
      # initialize/fit explainer
      epochs = 500
      embedding_dim = 4
      layers_config = []
      random_seed = 1
      neighbors = 5
      explainer = NearestNeighborContrastiveExplainer(
          embedding_dim=embedding_dim,
          layers_config=layers_config,
          neighbors=neighbors,
      )
  
      benign_exemplars = self.xx_train.iloc[
          np.where(self.y_train_onehot == 1)[0], :
      ]
  
      explainer.fit(
          self.xx_train,
          epochs=epochs,
          numeric_scaling=None,
          exemplars=benign_exemplars,
          random_seed=random_seed,
      )
  
      y_t_pred = np.round(self.model.predict(self.xx_test)).astype(int)
  
      xx_test_benign = self.xx_test.iloc[
          np.where(y_t_pred.reshape(-1) == 1)[0], :
      ]
  
      # compute explanations
      explanation = explainer.explain_instance(xx_test_benign.iloc[0])
  
      # 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.assertEquals(len(explanation["neighbors"]), neighbors)
      self.assertEquals(len(explanation["distances"]), neighbors)
  
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 2 for calling the TestNearestNeighborContrastiveExplainer obj's underlying member method code with example usage: obj.test_single_instance_only() without return types