class_docstr: Yields patches from data read from an image dataset.
  The patches are generated by a user-specified callable `patch_func`,
  and are optionally post-processed by `transform`.
  For example, to generate random patch samples from an image dataset:
  
  .. code-block:: python
  
      import numpy as np
  
      from monai.data import PatchDataset, DataLoader
      from monai.transforms import RandSpatialCropSamples, RandShiftIntensity
  
      # image dataset
      images = [np.arange(16, dtype=float).reshape(1, 4, 4),
                np.arange(16, dtype=float).reshape(1, 4, 4)]
      # image patch sampler
      n_samples = 5
      sampler = RandSpatialCropSamples(roi_size=(3, 3), num_samples=n_samples,
                                       random_center=True, random_size=False)
      # patch-level intensity shifts
      patch_intensity = RandShiftIntensity(offsets=1.0, prob=1.0)
      # construct the patch dataset
      ds = PatchDataset(dataset=images,
                        patch_func=sampler,
                        samples_per_image=n_samples,
                        transform=patch_intensity)
  
      # use the patch dataset, length: len(images) x samplers_per_image
      print(len(ds))
  
      >>> 10
  
      for item in DataLoader(ds, batch_size=2, shuffle=True, num_workers=2):
          print(item.shape)
  
      >>> torch.Size([2, 1, 3, 3])
class_docstr_tok: ["Yields","patches","from","data","read","from","an","image","dataset",".","The","patches","are","generated","by","a","user-specified","callable","`","patch_func","`",",","and","are","optionally","post-processed","by","`","transform","`",".","For","example",",","to","generate","random","patch","samples","from","an","image","dataset",":","..","code-block",":",":","python","import","numpy","as","np","from","monai.data","import","PatchDataset",",","DataLoader","from","monai.transforms","import","RandSpatialCropSamples",",","RandShiftIntensity","#","image","dataset","images","=","[","np.arange","(","16",",","dtype=float",")",".reshape","(","1",",","4",",","4",")",",","np.arange","(","16",",","dtype=float",")",".reshape","(","1",",","4",",","4",")","]","#","image","patch","sampler","n_samples","=","5","sampler","=","RandSpatialCropSamples","(","roi_size=","(","3",",","3",")",",","num_samples=n_samples",",","random_center=True",",","random_size=False",")","#","patch-level","intensity","shifts","patch_intensity","=","RandShiftIntensity","(","offsets=1.0",",","prob=1.0",")","#","construct","the","patch","dataset","ds","=","PatchDataset","(","dataset=images",",","patch_func=sampler",",","samples_per_image=n_samples",",","transform=patch_intensity",")","#","use","the","patch","dataset",",","length",":","len","(","images",")","x","samplers_per_image","print","(","len","(","ds",")",")",">",">",">","10","for","item","in","DataLoader","(","ds",",","batch_size=2",",","shuffle=True",",","num_workers=2",")",":","print","(","item.shape",")",">",">",">","torch.Size","(","[","2",",","1",",","3",",","3","]",")"]
code: def __len__(self) -> int:
      return len(self.data) * self.samples_per_image
  
imports: from __future__ import annotations
  import sys
  import warnings
  from collections.abc import Callable, Generator, Hashable, Iterable, Iterator, Mapping, Sequence
  from copy import deepcopy
  from multiprocessing.managers import ListProxy
  from multiprocessing.pool import ThreadPool
  from typing import TYPE_CHECKING
  import numpy
  import torch
  from monai.config import KeysCollection
  from monai.config.type_definitions import NdarrayTensor
  from monai.data.iterable_dataset import IterableDataset
  from monai.data.utils import iter_patch, pickle_hashing
  from monai.transforms import Compose, RandomizableTrait, Transform, apply_transform, convert_to_contiguous
  from monai.utils import NumpyPadMode, ensure_tuple, first, min_version, optional_import
label_desc: Use image node_id 2 for calling the PatchDataset obj's underlying member method code with example usage: obj.__len__() and returns: unknown