code: def sandwich_demo():
      x, y = sandwich_data()
      knn = nearest_neighbors(x, k=2)
      ax = plt.subplot(3, 1, 1)  # take the whole top row
      plot_sandwich_data(x, y, ax)
      plot_neighborhood_graph(x, knn, y, ax)
      ax.set_title("input space")
      ax.set_aspect("equal")
      ax.set_xticks([])
      ax.set_yticks([])
  
      mls = [
          LMNN(),
          ITML_Supervised(n_constraints=200),
          SDML_Supervised(n_constraints=200, balance_param=0.001),
          LSML_Supervised(n_constraints=200),
      ]
  
      for ax_num, ml in enumerate(mls, start=3):
          ml.fit(x, y)
          tx = ml.transform(x)
          ml_knn = nearest_neighbors(tx, k=2)
          ax = plt.subplot(3, 2, ax_num)
          plot_sandwich_data(tx, y, axis=ax)
          plot_neighborhood_graph(tx, ml_knn, y, axis=ax)
          ax.set_title(ml.__class__.__name__)
          ax.set_xticks([])
          ax.set_yticks([])
      plt.show()
  
file_path: metric-learn/examples/plot_sandwich.py
imports: import numpy
  from matplotlib import pyplot
  from sklearn.metrics import pairwise_distances
  from sklearn.neighbors import NearestNeighbors
  from metric_learn import LMNN, ITML_Supervised, LSML_Supervised, SDML_Supervised
label_desc: Use image node_id 1 for calling a global function with example usage: sandwich_demo() without return types