code: def reconstruct_from_patches_2d(patches, image_size):
      """Reconstruct the image from all of its patches.
  
      Patches are assumed to overlap and the image is constructed by filling in
      the patches from left to right, top to bottom, averaging the overlapping
      regions.
  
      Read more in the :ref:`User Guide <image_feature_extraction>`.
  
      Parameters
      ----------
      patches : ndarray of shape (n_patches, patch_height, patch_width) or \
          (n_patches, patch_height, patch_width, n_channels)
          The complete set of patches. If the patches contain colour information,
          channels are indexed along the last dimension: RGB patches would
          have `n_channels=3`.
  
      image_size : tuple of int (image_height, image_width) or \
          (image_height, image_width, n_channels)
          The size of the image that will be reconstructed.
  
      Returns
      -------
      image : ndarray of shape image_size
          The reconstructed image.
      """
      i_h, i_w = image_size[:2]
      p_h, p_w = patches.shape[1:3]
      img = np.zeros(image_size)
      # compute the dimensions of the patches array
      n_h = i_h - p_h + 1
      n_w = i_w - p_w + 1
      for p, (i, j) in zip(patches, product(range(n_h), range(n_w))):
          img[i : i + p_h, j : j + p_w] += p
  
      for i in range(i_h):
          for j in range(i_w):
              # divide by the amount of overlap
              # XXX: is this the most efficient way? memory-wise yes, cpu wise?
              img[i, j] /= float(
                  min(i + 1, p_h, i_h - i) * min(j + 1, p_w, i_w - j)
              )
      return img
  
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 10 for calling a global function with example usage: reconstruct_from_patches_2d(patches, image_size) and returns: img