code: def visualize(model_path, model, algo_name):
      if not MATPLOTLIB_AVAIBLABLE:
          logger.error("visualize requires matplotlib package ...")
          return
      pred = OfflinePredictor(
          PredictConfig(
              session_init=SmartInit(model_path),
              model=model(),
              input_names=["input"],
              output_names=["emb"],
          )
      )
  
      NUM_BATCHES = 6
      BATCH_SIZE = 128
      images = np.zeros(
          (BATCH_SIZE * NUM_BATCHES, 28, 28)
      )  # the used digits
      embed = np.zeros(
          (BATCH_SIZE * NUM_BATCHES, 2)
      )  # the actual embeddings in 2-d
  
      # get only the embedding model data (MNIST test)
      ds = get_test_data()
      ds.reset_state()
  
      for offset, dp in enumerate(ds):
          digit, label = dp
          prediction = pred(digit)[0]
          embed[
              offset * BATCH_SIZE : offset * BATCH_SIZE + BATCH_SIZE,
              ...,
          ] = prediction
          images[
              offset * BATCH_SIZE : offset * BATCH_SIZE + BATCH_SIZE,
              ...,
          ] = digit
          offset += 1
          if offset == NUM_BATCHES:
              break
  
      plt.figure()
      ax = plt.subplot(111)
      ax_min = np.min(embed, 0)
      ax_max = np.max(embed, 0)
  
      ax_dist_sq = np.sum((ax_max - ax_min) ** 2)
      ax.axis("off")
      shown_images = np.array([[1.0, 1.0]])
      for i in range(embed.shape[0]):
          dist = np.sum((embed[i] - shown_images) ** 2, 1)
          if (
              np.min(dist) < 3e-4 * ax_dist_sq
          ):  # don't show points that are too close
              continue
          shown_images = np.r_[shown_images, [embed[i]]]
          imagebox = offsetbox.AnnotationBbox(
              offsetbox.OffsetImage(
                  np.reshape(images[i, ...], [28, 28]),
                  zoom=0.6,
                  cmap=plt.cm.gray_r,
              ),
              xy=embed[i],
              frameon=False,
          )
          ax.add_artist(imagebox)
  
      plt.axis([ax_min[0], ax_max[0], ax_min[1], ax_max[1]])
      plt.xticks([]), plt.yticks([])
      plt.title("Embedding using %s-loss" % algo_name)
      plt.savefig("%s.jpg" % algo_name)
  
imports: import argparse
  import numpy
  import tensorflow
  import tensorflow.contrib.slim
  from tensorpack import *
  from tensorpack.tfutils.summary import add_moving_summary
  from tensorpack.utils.gpu import change_gpu
  from embedding_data import MnistPairs, MnistTriplets, get_test_data
label_desc: Use image node_id 7 for calling a global function with example usage: visualize(model_path, model, algo_name) without return types