code: def _extract_patches(arr, patch_shape=8, extraction_step=1):
      """Extracts patches of any n-dimensional array in place using strides.
  
      Given an n-dimensional array it will return a 2n-dimensional array with
      the first n dimensions indexing patch position and the last n indexing
      the patch content. This operation is immediate (O(1)). A reshape
      performed on the first n dimensions will cause numpy to copy data, leading
      to a list of extracted patches.
  
      Read more in the :ref:`User Guide <image_feature_extraction>`.
  
      Parameters
      ----------
      arr : ndarray
          n-dimensional array of which patches are to be extracted
  
      patch_shape : int or tuple of length arr.ndim.default=8
          Indicates the shape of the patches to be extracted. If an
          integer is given, the shape will be a hypercube of
          sidelength given by its value.
  
      extraction_step : int or tuple of length arr.ndim, default=1
          Indicates step size at which extraction shall be performed.
          If integer is given, then the step is uniform in all dimensions.
  
  
      Returns
      -------
      patches : strided ndarray
          2n-dimensional array indexing patches on first n dimensions and
          containing patches on the last n dimensions. These dimensions
          are fake, but this way no data is copied. A simple reshape invokes
          a copying operation to obtain a list of patches:
          result.reshape([-1] + list(patch_shape))
      """
  
      arr_ndim = arr.ndim
  
      if isinstance(patch_shape, Number):
          patch_shape = tuple([patch_shape] * arr_ndim)
      if isinstance(extraction_step, Number):
          extraction_step = tuple([extraction_step] * arr_ndim)
  
      patch_strides = arr.strides
  
      slices = tuple(slice(None, None, st) for st in extraction_step)
      indexing_strides = arr[slices].strides
  
      patch_indices_shape = (
          (np.array(arr.shape) - np.array(patch_shape))
          // np.array(extraction_step)
      ) + 1
  
      shape = tuple(list(patch_indices_shape) + list(patch_shape))
      strides = tuple(list(indexing_strides) + list(patch_strides))
  
      patches = as_strided(arr, shape=shape, strides=strides)
      return patches
  
imports: from itertools import product
  from numbers import Integral, Number, Real
  import numpy
  from numpy.lib.stride_tricks import as_strided
  from scipy import sparse
  from ..base import BaseEstimator, TransformerMixin, _fit_context
  from ..utils import check_array, check_random_state
  from ..utils._param_validation import Hidden, Interval, RealNotInt, validate_params
label_desc: Use image node_id 8 for calling a global function with example usage: _extract_patches(arr, patch_shape, extraction_step) and returns: patches