code: def plot_knn_examples(
      embeddings, filenames, n_neighbors=3, num_examples=6
  ):
      """Plots multiple rows of random images with their nearest neighbors"""
      # lets look at the nearest neighbors for some samples
      # we use the sklearn library
      nbrs = NearestNeighbors(n_neighbors=n_neighbors).fit(embeddings)
      distances, indices = nbrs.kneighbors(embeddings)
  
      # get 5 random samples
      samples_idx = np.random.choice(
          len(indices), size=num_examples, replace=False
      )
  
      # loop through our randomly picked samples
      for idx in samples_idx:
          fig = plt.figure()
          # loop through their nearest neighbors
          for plot_x_offset, neighbor_idx in enumerate(indices[idx]):
              # add the subplot
              ax = fig.add_subplot(
                  1, len(indices[idx]), plot_x_offset + 1
              )
              # get the correponding filename for the current index
              fname = os.path.join(
                  path_to_data, filenames[neighbor_idx]
              )
              # plot the image
              plt.imshow(get_image_as_np_array(fname))
              # set the title to the distance of the neighbor
              ax.set_title(f"d={distances[idx][plot_x_offset]:.3f}")
              # let's disable the axis
              plt.axis("off")
  
imports: import os
  import matplotlib.pyplot
  import numpy
  import pytorch_lightning
  import torch
  import torch.nn
  import torchvision
  from PIL import Image
  from sklearn.neighbors import NearestNeighbors
  from sklearn.preprocessing import normalize
  from lightly.data import LightlyDataset
  from lightly.transforms import SimCLRTransform, utils
  from lightly.loss import NTXentLoss
  from lightly.models.modules.heads import SimCLRProjectionHead
label_desc: Use image node_id 3 for calling a global function with example usage: plot_knn_examples(embeddings, filenames, n_neighbors, num_examples) without return types