class_docstr: Return a patch generator with predefined properties such as `patch_size`.
  Typically used with :py:class:`monai.data.GridPatchDataset`.
class_docstr_tok: ["Return","a","patch","generator","with","predefined","properties","such","as","`","patch_size","`",".","Typically","used","with",":","py",":","class",":","`","monai.data.GridPatchDataset","`","."]
docstr: Args:
      patch_size: size of patches to generate slices for, 0/None selects whole dimension
      start_pos: starting position in the array, default is 0 for each dimension
      mode: available modes: (Numpy) {``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
          ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
          (PyTorch) {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
          One of the listed string values or a user supplied function.
          If None, no wrapping is performed. Defaults to ``"wrap"``.
          See also: https://numpy.org/doc/stable/reference/generated/numpy.pad.html
          https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
          requires pytorch >= 1.10 for best compatibility.
      pad_opts: other arguments for the `np.pad` function.
          note that `np.pad` treats channel dimension as the first dimension.
  
  Note:
      The `patch_size` is the size of the
      patch to sample from the input arrays. It is assumed the arrays first dimension is the channel dimension which
      will be yielded in its entirety so this should not be specified in `patch_size`. For example, for an input 3D
      array with 1 channel of size (1, 20, 20, 20) a regular grid sampling of eight patches (1, 10, 10, 10) would be
      specified by a `patch_size` of (10, 10, 10).
docstr_tok: ["Args",":","patch_size",":","size","of","patches","to","generate","slices","for",",","0\/None","selects","whole","dimension","start_pos",":","starting","position","in","the","array",",","default","is","0","for","each","dimension","mode",":","available","modes",":","(","Numpy",")","{","``","``","constant","''","``",",","``","``","edge","''","``",",","``","``","linear_ramp","''","``",",","``","``","maximum","''","``",",","``","``","mean","''","``",",","``","``","median","''","``",",","``","``","minimum","''","``",",","``","``","reflect","''","``",",","``","``","symmetric","''","``",",","``","``","wrap","''","``",",","``","``","empty","''","``","}","(","PyTorch",")","{","``","``","constant","''","``",",","``","``","reflect","''","``",",","``","``","replicate","''","``",",","``","``","circular","''","``","}",".","One","of","the","listed","string","values","or","a","user","supplied","function",".","If","None",",","no","wrapping","is","performed",".","Defaults","to","``","``","wrap","''","``",".","See","also",":","https",":","\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.pad.html","https",":","\/\/pytorch.org\/docs\/stable\/generated\/torch.nn.functional.pad.html","requires","pytorch",">","=","1.10","for","best","compatibility",".","pad_opts",":","other","arguments","for","the","`","np.pad","`","function",".","note","that","`","np.pad","`","treats","channel","dimension","as","the","first","dimension",".","Note",":","The","`","patch_size","`","is","the","size","of","the","patch","to","sample","from","the","input","arrays",".","It","is","assumed","the","arrays","first","dimension","is","the","channel","dimension","which","will","be","yielded","in","its","entirety","so","this","should","not","be","specified","in","`","patch_size","`",".","For","example",",","for","an","input","3D","array","with","1","channel","of","size","(","1",",","20",",","20",",","20",")","a","regular","grid","sampling","of","eight","patches","(","1",",","10",",","10",",","10",")","would","be","specified","by","a","`","patch_size","`","of","(","10",",","10",",","10",")","."]
code: def __init__(
      self,
      patch_size: Sequence[int],
      start_pos: Sequence[int] = (),
      mode: str | None = NumpyPadMode.WRAP,
      **pad_opts: dict,
  ):
      """
  
      Args:
          patch_size: size of patches to generate slices for, 0/None selects whole dimension
          start_pos: starting position in the array, default is 0 for each dimension
          mode: available modes: (Numpy) {``"constant"``, ``"edge"``, ``"linear_ramp"``, ``"maximum"``,
              ``"mean"``, ``"median"``, ``"minimum"``, ``"reflect"``, ``"symmetric"``, ``"wrap"``, ``"empty"``}
              (PyTorch) {``"constant"``, ``"reflect"``, ``"replicate"``, ``"circular"``}.
              One of the listed string values or a user supplied function.
              If None, no wrapping is performed. Defaults to ``"wrap"``.
              See also: https://numpy.org/doc/stable/reference/generated/numpy.pad.html
              https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
              requires pytorch >= 1.10 for best compatibility.
          pad_opts: other arguments for the `np.pad` function.
              note that `np.pad` treats channel dimension as the first dimension.
  
      Note:
          The `patch_size` is the size of the
          patch to sample from the input arrays. It is assumed the arrays first dimension is the channel dimension which
          will be yielded in its entirety so this should not be specified in `patch_size`. For example, for an input 3D
          array with 1 channel of size (1, 20, 20, 20) a regular grid sampling of eight patches (1, 10, 10, 10) would be
          specified by a `patch_size` of (10, 10, 10).
  
      """
      self.patch_size = (None,) + tuple(
          patch_size
      )  # expand to have the channel dim
      self.start_pos = ensure_tuple(start_pos)
      self.mode = mode
      self.pad_opts = pad_opts
  
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 1 to create a new PatchIter object  with example: obj = PatchIter(patch_size, start_pos, mode)