class_docstr: This dataset extracts patches in sliding-window manner from whole slide images (without loading the whole image).
  It also reads labels for each patch and provides each patch with its associated class labels.
  
  Args:
      data: the list of input samples including image, location, and label (see the note below for more details).
      patch_size: the size of patch to be extracted from the whole slide image.
      patch_level: the level at which the patches to be extracted (default to 0).
      mask_level: the resolution level at which the mask/map is created (for `ProbMapProducer` for instance).
      overlap: the amount of overlap of neighboring patches in each dimension (a value between 0.0 and 1.0).
          If only one float number is given, it will be applied to all dimensions. Defaults to 0.0.
      offset: the offset of image to extract patches (the starting position of the upper left patch).
      offset_limits: if offset is set to "random", a tuple of integers defining the lower and upper limit of the
          random offset for all dimensions, or a tuple of tuples that defines the limits for each dimension.
      transform: transforms to be executed on input data.
      include_label: whether to load and include labels in the output
      center_location: whether the input location information is the position of the center of the patch
      additional_meta_keys: the list of keys for items to be copied to the output metadata from the input data
      reader: the module to be used for loading whole slide imaging. Defaults to cuCIM. If `reader` is
  
          - a string, it defines the backend of `monai.data.WSIReader`.
          - a class (inherited from `BaseWSIReader`), it is initialized and set as wsi_reader,
          - an instance of a class inherited from `BaseWSIReader`, it is set as the wsi_reader.
  
      seed: random seed to randomly generate offsets. Defaults to 0.
      kwargs: additional arguments to pass to `WSIReader` or provided whole slide reader class
  
  Note:
      The input data has the following form as an example:
  
      .. code-block:: python
  
          [
              {"image": "path/to/image1.tiff"},
              {"image": "path/to/image2.tiff", "patch_size": [20, 20], "patch_level": 2}
          ]
  
      Unlike `MaskedPatchWSIDataset`, this dataset does not filter any patches.
class_docstr_tok: ["This","dataset","extracts","patches","in","sliding-window","manner","from","whole","slide","images","(","without","loading","the","whole","image",")",".","It","also","reads","labels","for","each","patch","and","provides","each","patch","with","its","associated","class","labels",".","Args",":","data",":","the","list","of","input","samples","including","image",",","location",",","and","label","(","see","the","note","below","for","more","details",")",".","patch_size",":","the","size","of","patch","to","be","extracted","from","the","whole","slide","image",".","patch_level",":","the","level","at","which","the","patches","to","be","extracted","(","default","to","0",")",".","mask_level",":","the","resolution","level","at","which","the","mask\/map","is","created","(","for","`","ProbMapProducer","`","for","instance",")",".","overlap",":","the","amount","of","overlap","of","neighboring","patches","in","each","dimension","(","a","value","between","0.0","and","1.0",")",".","If","only","one","float","number","is","given",",","it","will","be","applied","to","all","dimensions",".","Defaults","to","0.0.","offset",":","the","offset","of","image","to","extract","patches","(","the","starting","position","of","the","upper","left","patch",")",".","offset_limits",":","if","offset","is","set","to","``","random","''",",","a","tuple","of","integers","defining","the","lower","and","upper","limit","of","the","random","offset","for","all","dimensions",",","or","a","tuple","of","tuples","that","defines","the","limits","for","each","dimension",".","transform",":","transforms","to","be","executed","on","input","data",".","include_label",":","whether","to","load","and","include","labels","in","the","output","center_location",":","whether","the","input","location","information","is","the","position","of","the","center","of","the","patch","additional_meta_keys",":","the","list","of","keys","for","items","to","be","copied","to","the","output","metadata","from","the","input","data","reader",":","the","module","to","be","used","for","loading","whole","slide","imaging",".","Defaults","to","cuCIM",".","If","`","reader","`","is","-","a","string",",","it","defines","the","backend","of","`","monai.data.WSIReader","`",".","-","a","class","(","inherited","from","`","BaseWSIReader","`",")",",","it","is","initialized","and","set","as","wsi_reader",",","-","an","instance","of","a","class","inherited","from","`","BaseWSIReader","`",",","it","is","set","as","the","wsi_reader",".","seed",":","random","seed","to","randomly","generate","offsets",".","Defaults","to","0.","kwargs",":","additional","arguments","to","pass","to","`","WSIReader","`","or","provided","whole","slide","reader","class","Note",":","The","input","data","has","the","following","form","as","an","example",":","..","code-block",":",":","python","[","{","``","image","''",":","``","path\/to\/image1.tiff","''","}",",","{","``","image","''",":","``","path\/to\/image2.tiff","''",",","``","patch_size","''",":","[","20",",","20","]",",","``","patch_level","''",":","2","}","]","Unlike","`","MaskedPatchWSIDataset","`",",","this","dataset","does","not","filter","any","patches","."]
code: def __init__(
      self,
      data: Sequence,
      patch_size: int | tuple[int, int] | None = None,
      patch_level: int | None = None,
      mask_level: int = 0,
      overlap: tuple[float, float] | float = 0.0,
      offset: tuple[int, int] | int | str = (0, 0),
      offset_limits: tuple[tuple[int, int], tuple[int, int]]
      | tuple[int, int]
      | None = None,
      transform: Callable | None = None,
      include_label: bool = False,
      center_location: bool = False,
      additional_meta_keys: Sequence[str] = (
          ProbMapKeys.LOCATION,
          ProbMapKeys.SIZE,
          ProbMapKeys.COUNT,
      ),
      reader="cuCIM",
      seed: int = 0,
      **kwargs,
  ):
      super().__init__(
          data=[],
          patch_size=patch_size,
          patch_level=patch_level,
          transform=transform,
          include_label=include_label,
          center_location=center_location,
          additional_meta_keys=additional_meta_keys,
          reader=reader,
          **kwargs,
      )
      self.overlap = overlap
      self.set_random_state(seed)
      # Set the offset config
      self.random_offset = False
      if isinstance(offset, str):
          if offset == "random":
              self.random_offset = True
              self.offset_limits: tuple[
                  tuple[int, int], tuple[int, int]
              ] | None
              if offset_limits is None:
                  self.offset_limits = None
              elif isinstance(offset_limits, tuple):
                  if isinstance(offset_limits[0], int):
                      self.offset_limits = (
                          offset_limits,
                          offset_limits,
                      )
                  elif isinstance(offset_limits[0], tuple):
                      self.offset_limits = offset_limits
                  else:
                      raise ValueError(
                          "The offset limits should be either a tuple of integers or tuple of tuple of integers."
                      )
              else:
                  raise ValueError(
                      "The offset limits should be a tuple."
                  )
          else:
              raise ValueError(
                  f'Invalid string for offset "{offset}". It should be either "random" as a string,'
                  "an integer, or a tuple of integers defining the offset."
              )
      else:
          self.offset = ensure_tuple_rep(offset, 2)
  
      self.mask_level = mask_level
      # Create single sample for each patch (in a sliding window manner)
      self.data: list
      self.image_data = list(data)
      for sample in self.image_data:
          patch_samples = self._evaluate_patch_locations(sample)
          self.data.extend(patch_samples)
  
imports: from __future__ import annotations
  import inspect
  import os
  from collections.abc import Callable, Sequence
  import numpy
  import torch
  from monai.data import Dataset
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import iter_patch_position
  from monai.data.wsi_reader import BaseWSIReader, WSIReader
  from monai.transforms import ForegroundMask, Randomizable, apply_transform
  from monai.utils import convert_to_dst_type, ensure_tuple_rep
  from monai.utils.enums import CommonKeys, ProbMapKeys, WSIPatchKeys
label_desc: Use image node_id 1 to create a new SlidingPatchWSIDataset object from inherited base classes: Randomizable, PatchWSIDataset with example: obj = SlidingPatchWSIDataset(data, patch_size, patch_level, mask_level, overlap, offset, offset_limits, transform, include_label, center_location, additional_meta_keys, reader, seed)