class_docstr: Extracts patches from a collection of images
  
  Read more in the :ref:`User Guide <image_feature_extraction>`.
  
  Parameters
  ----------
  patch_size : tuple of ints (patch_height, patch_width)
      the dimensions of one patch
  
  max_patches : integer or float, optional default is 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.
  
  random_state : int or RandomState
      Pseudo number generator state used for random sampling.
docstr: Transforms the image samples in X into a matrix of patch data.
  
  Parameters
  ----------
  X : array, shape = (n_samples, image_height, image_width) or
      (n_samples, image_height, image_width, n_channels)
      Array of images from which to extract patches. For color images,
      the last dimension specifies the channel: a RGB image would have
      `n_channels=3`.
  
  Returns
  -------
  patches: array, shape = (n_patches, patch_height, patch_width) or
       (n_patches, patch_height, patch_width, n_channels)
       The collection of patches extracted from the images, where
       `n_patches` is either `n_samples * max_patches` or the total
       number of patches that can be extracted.
docstr_tok: ["Transforms","the","image","samples","in","X","into","a","matrix","of","patch","data",".","Parameters","--","--","--","--","--","X",":","array",",","shape","=","(","n_samples",",","image_height",",","image_width",")","or","(","n_samples",",","image_height",",","image_width",",","n_channels",")","Array","of","images","from","which","to","extract","patches",".","For","color","images",",","the","last","dimension","specifies","the","channel",":","a","RGB","image","would","have","`","n_channels=3","`",".","Returns","--","--","--","-","patches",":","array",",","shape","=","(","n_patches",",","patch_height",",","patch_width",")","or","(","n_patches",",","patch_height",",","patch_width",",","n_channels",")","The","collection","of","patches","extracted","from","the","images",",","where","`","n_patches","`","is","either","`","n_samples","*","max_patches","`","or","the","total","number","of","patches","that","can","be","extracted","."]
code: def transform(self, X):
      """Transforms the image samples in X into a matrix of patch data.
  
      Parameters
      ----------
      X : array, shape = (n_samples, image_height, image_width) or
          (n_samples, image_height, image_width, n_channels)
          Array of images from which to extract patches. For color images,
          the last dimension specifies the channel: a RGB image would have
          `n_channels=3`.
  
      Returns
      -------
      patches: array, shape = (n_patches, patch_height, patch_width) or
           (n_patches, patch_height, patch_width, n_channels)
           The collection of patches extracted from the images, where
           `n_patches` is either `n_samples * max_patches` or the total
           number of patches that can be extracted.
  
      """
      self.random_state = check_random_state(self.random_state)
      n_images, i_h, i_w = X.shape[:3]
      X = np.reshape(X, (n_images, i_h, i_w, -1))
      n_channels = X.shape[-1]
      if self.patch_size is None:
          patch_size = i_h // 10, i_w // 10
      else:
          patch_size = self.patch_size
  
      # compute the dimensions of the patches array
      p_h, p_w = patch_size
      n_patches = _compute_n_patches(
          i_h, i_w, p_h, p_w, self.max_patches
      )
      patches_shape = (n_images * n_patches,) + patch_size
      if n_channels > 1:
          patches_shape += (n_channels,)
  
      # extract the patches
      patches = np.empty(patches_shape)
      for ii, image in enumerate(X):
          patches[
              ii * n_patches : (ii + 1) * n_patches
          ] = extract_patches_2d(
              image, patch_size, self.max_patches, self.random_state
          )
      return patches
  
imports: from itertools import product
  import numbers
  import numpy
  from scipy import sparse
  from numpy.lib.stride_tricks import as_strided
  from ..utils import check_array, check_random_state
  from ..utils.fixes import astype
  from ..base import BaseEstimator
label_desc: Use image node_id 3 for calling the PatchExtractor obj's underlying member method code with example usage: obj.transform(X) and returns: patches