code: def visualize_image_prototypes(
      summary: "Explanation",
      trainset: Tuple[np.ndarray, np.ndarray],
      reducer: Callable[[np.ndarray], np.ndarray],
      preprocess_fn: Optional[
          Callable[[np.ndarray], np.ndarray]
      ] = None,
      knn_kw: Optional[dict] = None,
      ax: Optional[plt.Axes] = None,
      fig_kw: Optional[dict] = None,
      image_size: Tuple[int, int] = (28, 28),
      zoom_lb: float = 1.0,
      zoom_ub: float = 3.0,
  ) -> plt.Axes:
      """
      Plot the images of the prototypes at the location given by the `reducer` representation.
      The size of each prototype is proportional to the logarithm of the number of assigned training instances correctly
      classified according to the 1-KNN classifier (Bien and Tibshirani (2012): https://arxiv.org/abs/1202.5933).
  
      Parameters
      ----------
      summary
          An `Explanation` object produced by a call to the
          :py:meth:`alibi.prototypes.protoselect.ProtoSelect.summarise` method.
      trainset
          Tuple, `(X_train, y_train)`, consisting of the training data instances with the corresponding labels.
      reducer
          2D reducer. Reduces the input feature representation to 2D. Note that the reducer operates directly on the
          input instances if ``preprocess_fn=None``. If the `preprocess_fn` is specified, the reducer will be called
          on the feature representation obtained after passing the input instances through the `preprocess_fn`.
      preprocess_fn
          Optional preprocessor function. If ``preprocess_fn=None``, no preprocessing is applied.
      knn_kw
          Keyword arguments passed to `sklearn.neighbors.KNeighborsClassifier`. The `n_neighbors` will be
          set automatically to 1, but the `metric` has to be specified according to the kernel distance used.
          If the `metric` is not specified, it will be set by default to ``'euclidean'``.
          See parameters description:
          https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
      ax
          A `matplotlib` axes object to plot on.
      fig_kw
          Keyword arguments passed to the `fig.set` function.
      image_size
          Shape to which the prototype images will be resized. A zoom of 1 will display the image having the shape
          `image_size`.
      zoom_lb
          Zoom lower bound. The zoom will be scaled linearly between `[zoom_lb, zoom_ub]`.
      zoom_ub
          Zoom upper bound. The zoom will be scaled linearly between `[zoom_lb, zoom_ub]`.
      """
      # compute how many correct labeled instances each prototype covers
      protos_importance = compute_prototype_importances(
          summary=summary,
          trainset=trainset,
          preprocess_fn=preprocess_fn,
          knn_kw=knn_kw,
      )
  
      # unpack values
      counts = protos_importance["prototype_importances"]
      X_protos = protos_importance["X_protos"]
      X_protos_ft = (
          protos_importance["X_protos_ft"]
          if (protos_importance["X_protos_ft"] is not None)
          else X_protos
      )
  
      # compute image zoom
      zoom = np.log(counts)  # type: ignore[arg-type]
  
      # compute 2D embedding
      protos_2d = reducer(X_protos_ft)  # type: ignore[arg-type]
      x, y = protos_2d[:, 0], protos_2d[:, 1]
  
      # plot images
      return _imscatterplot(
          x=x,
          y=y,
          images=X_protos,  # type: ignore[arg-type]
          ax=ax,
          fig_kw=fig_kw,
          image_size=image_size,
          zoom=zoom,
          zoom_lb=zoom_lb,
          zoom_ub=zoom_ub,
      )
  
imports: import logging
  from copy import deepcopy
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import numpy
  from matplotlib.offsetbox import AnnotationBbox, OffsetImage
  from skimage.transform import resize
  from sklearn.model_selection import KFold
  from sklearn.neighbors import KNeighborsClassifier
  from tqdm import tqdm
  from alibi.api.defaults import DEFAULT_DATA_PROTOSELECT, DEFAULT_META_PROTOSELECT
  from alibi.api.interfaces import Explanation, FitMixin, Summariser
  from alibi.utils.distance import batch_compute_kernel_matrix
  from alibi.utils.kernel import EuclideanDistance
label_desc: Use image node_id 7 for calling a global function with example usage: visualize_image_prototypes(summary, trainset, reducer, preprocess_fn, knn_kw, ax, fig_kw, image_size, zoom_lb, zoom_ub) and returns: _imscatterplot