class_docstr: Splits the whole slide image input into patches with sliding window strategy and a possible overlap.
  This extracts patches from file without loading the entire slide into memory.
  It also allows offsetting the starting position and filtering the patches.
  
  Args:
      patch_size : the size of the patches to be generated.
      offset: the amount of offset for the patches with respect to the original input.  Defaults to 0.
      overlap: the amount of overlap between patches in each dimension. It can be either a float in
          the range of [0.0, 1.0) that defines relative overlap to the patch size, or it can be a non-negative int
          that defines number of pixels for overlap. Defaults to 0.0.
      filter_fn: a callable to filter patches. It should accepts exactly two parameters (patch, location), and
          return True for a patch to keep. Defaults to no filtering.
      pad_mode: define the mode for padding. Either "constant" or None. Default to "constant".
          Padding is only supported with "OpenSlide" or "cuCIM" backend, and the filling value is 256.
      device: the device where the patches are generated. Defaults to the device of inputs.
      reader: the module to be used for loading whole slide imaging. If `reader` is
  
          - a string, it defines the backend of `monai.data.WSIReader`. Defaults to "OpenSlide".
          - 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.
  
          To obtain an optimized performance please use either "cuCIM" or "OpenSlide" backend.
      reader_kwargs: the arguments to pass to `WSIReader` or the provided whole slide reader class.
          For instance, level=2, dtype=torch.float32, etc.
          Note that if `level` is not provided, `level=0` is assumed.
  
  Note:
      When a scaler value is provided for `patch_size`, `offset`, or `overlap`,
      it is broadcasted to all the spatial dimensions.
class_docstr_tok: ["Splits","the","whole","slide","image","input","into","patches","with","sliding","window","strategy","and","a","possible","overlap",".","This","extracts","patches","from","file","without","loading","the","entire","slide","into","memory",".","It","also","allows","offsetting","the","starting","position","and","filtering","the","patches",".","Args",":","patch_size",":","the","size","of","the","patches","to","be","generated",".","offset",":","the","amount","of","offset","for","the","patches","with","respect","to","the","original","input",".","Defaults","to","0.","overlap",":","the","amount","of","overlap","between","patches","in","each","dimension",".","It","can","be","either","a","float","in","the","range","of","[","0.0",",","1.0",")","that","defines","relative","overlap","to","the","patch","size",",","or","it","can","be","a","non-negative","int","that","defines","number","of","pixels","for","overlap",".","Defaults","to","0.0.","filter_fn",":","a","callable","to","filter","patches",".","It","should","accepts","exactly","two","parameters","(","patch",",","location",")",",","and","return","True","for","a","patch","to","keep",".","Defaults","to","no","filtering",".","pad_mode",":","define","the","mode","for","padding",".","Either","``","constant","''","or","None",".","Default","to","``","constant","''",".","Padding","is","only","supported","with","``","OpenSlide","''","or","``","cuCIM","''","backend",",","and","the","filling","value","is","256.","device",":","the","device","where","the","patches","are","generated",".","Defaults","to","the","device","of","inputs",".","reader",":","the","module","to","be","used","for","loading","whole","slide","imaging",".","If","`","reader","`","is","-","a","string",",","it","defines","the","backend","of","`","monai.data.WSIReader","`",".","Defaults","to","``","OpenSlide","''",".","-","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",".","To","obtain","an","optimized","performance","please","use","either","``","cuCIM","''","or","``","OpenSlide","''","backend",".","reader_kwargs",":","the","arguments","to","pass","to","`","WSIReader","`","or","the","provided","whole","slide","reader","class",".","For","instance",",","level=2",",","dtype=torch.float32",",","etc",".","Note","that","if","`","level","`","is","not","provided",",","`","level=0","`","is","assumed",".","Note",":","When","a","scaler","value","is","provided","for","`","patch_size","`",",","`","offset","`",",","or","`","overlap","`",",","it","is","broadcasted","to","all","the","spatial","dimensions","."]
docstr: Set the WSI reader object based on the input reader
  
  Args:
      reader: the module to be used for loading whole slide imaging. If `reader` is
  
          - a string, it defines the backend of `monai.data.WSIReader`. Defaults to cuCIM.
          - 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.
docstr_tok: ["Set","the","WSI","reader","object","based","on","the","input","reader","Args",":","reader",":","the","module","to","be","used","for","loading","whole","slide","imaging",".","If","`","reader","`","is","-","a","string",",","it","defines","the","backend","of","`","monai.data.WSIReader","`",".","Defaults","to","cuCIM",".","-","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","."]
code: def _set_reader(
      self,
      reader: str | BaseWSIReader | type[BaseWSIReader] | None,
      reader_kwargs: dict,
  ) -> None:
      """
      Set the WSI reader object based on the input reader
  
      Args:
          reader: the module to be used for loading whole slide imaging. If `reader` is
  
              - a string, it defines the backend of `monai.data.WSIReader`. Defaults to cuCIM.
              - 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.
      """
      self.reader: WSIReader | BaseWSIReader
      self.reader_kwargs = reader_kwargs
      if isinstance(reader, str):
          self.reader = WSIReader(backend=reader, **self.reader_kwargs)
      elif isclass(reader) and issubclass(reader, BaseWSIReader):
          self.reader = reader(**self.reader_kwargs)
      elif isinstance(reader, BaseWSIReader):
          self.reader = reader
      else:
          raise ValueError(f"Unsupported reader type: {reader}.")
  
imports: from __future__ import annotations
  import os
  import warnings
  from abc import ABC, abstractmethod
  from collections.abc import Callable, Iterable, Sequence
  from inspect import _empty, isclass, signature
  from typing import Any
  import torch
  from monai.data.utils import iter_patch_position
  from monai.data.wsi_reader import BaseWSIReader, WSIReader
  from monai.transforms.utility.array import convert_to_tensor
  from monai.utils.misc import PathLike, ensure_tuple, ensure_tuple_rep
label_desc: Use image node_id 2 for calling the WSISlidingWindowSplitter obj's underlying member method code with example usage: obj._set_reader(reader, reader_kwargs) without return types