code: def _batch_preprocessing(
      X: np.ndarray,
      preprocess_fn: Callable[[np.ndarray], np.ndarray],
      batch_size: int = 32,
  ) -> np.ndarray:
      """
      Preprocess a dataset `X` in batches by applying the preprocessor function.
  
      Parameters
      ----------
      X
          Dataset to be preprocessed.
      preprocess_fn
          Preprocessor function.
      batch_size
          Batch size to be used for each call to `preprocess_fn`.
  
      Returns
      -------
      Preprocessed dataset.
      """
      X_ft = []
      num_iter = int(np.ceil(len(X) / batch_size))
  
      for i in range(num_iter):
          istart, iend = batch_size * i, min(
              batch_size * (i + 1), len(X)
          )
          X_ft.append(preprocess_fn(X[istart:iend]))
  
      return np.concatenate(X_ft, axis=0)
  
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 4 for calling a global function with example usage: _batch_preprocessing(X, preprocess_fn, batch_size) and returns: np