class_docstr: Extracts patches from a collection of images.
  
  Read more in the :ref:`User Guide <image_feature_extraction>`.
  
  .. versionadded:: 0.9
  
  Parameters
  ----------
  patch_size : tuple of int (patch_height, patch_width), default=None
      The dimensions of one patch. If set to None, the patch size will be
      automatically set to `(img_height // 10, img_width // 10)`, where
      `img_height` and `img_width` are the dimensions of the input images.
  
  max_patches : int or float, default=None
      The maximum number of patches per image to extract. If `max_patches` is
      a float in (0, 1), it is taken to mean a proportion of the total number
      of patches. If set to None, extract all possible patches.
  
  random_state : int, RandomState instance, default=None
      Determines the random number generator used for random sampling when
      `max_patches is not None`. Use an int to make the randomness
      deterministic.
      See :term:`Glossary <random_state>`.
  
  See Also
  --------
  reconstruct_from_patches_2d : Reconstruct image from all of its patches.
  
  Notes
  -----
  This estimator is stateless and does not need to be fitted. However, we
  recommend to call :meth:`fit_transform` instead of :meth:`transform`, as
  parameter validation is only performed in :meth:`fit`.
  
  Examples
  --------
  >>> from sklearn.datasets import load_sample_images
  >>> from sklearn.feature_extraction import image
  >>> # Use the array data from the second image in this dataset:
  >>> X = load_sample_images().images[1]
  >>> X = X[None, ...]
  >>> print(f"Image shape: {X.shape}")
  Image shape: (1, 427, 640, 3)
  >>> pe = image.PatchExtractor(patch_size=(10, 10))
  >>> pe_trans = pe.transform(X)
  >>> print(f"Patches shape: {pe_trans.shape}")
  Patches shape: (263758, 10, 10, 3)
  >>> X_reconstructed = image.reconstruct_from_patches_2d(pe_trans, X.shape[1:])
  >>> print(f"Reconstructed shape: {X_reconstructed.shape}")
  Reconstructed shape: (427, 640, 3)
code: def __init__(
      self, *, patch_size=None, max_patches=None, random_state=None
  ):
      self.patch_size = patch_size
      self.max_patches = max_patches
      self.random_state = random_state
  
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 1 to create a new PatchExtractor object from inherited base classes: TransformerMixin, BaseEstimator with example: obj = PatchExtractor()