class_docstr: This dataset extracts patches from whole slide images at the locations where foreground mask
  at a given level is non-zero.
  
  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 is created.
      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.
  
      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", "size": [20, 20], "level": 2}
          ]
class_docstr_tok: ["This","dataset","extracts","patches","from","whole","slide","images","at","the","locations","where","foreground","mask","at","a","given","level","is","non-zero",".","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","is","created",".","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",".","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","''",",","``","size","''",":","[","20",",","20","]",",","``","level","''",":","2","}","]"]
docstr: Calculate the location for each patch based on the mask at different resolution level
docstr_tok: ["Calculate","the","location","for","each","patch","based","on","the","mask","at","different","resolution","level"]
code: def _evaluate_patch_locations(self, sample):
      """Calculate the location for each patch based on the mask at different resolution level"""
      patch_size = self._get_size(sample)
      patch_level = self._get_level(sample)
      wsi_obj = self._get_wsi_object(sample)
  
      # load the entire image at level=mask_level
      wsi, _ = self.wsi_reader.get_data(wsi_obj, level=self.mask_level)
  
      # create the foreground tissue mask and get all indices for non-zero pixels
      mask = np.squeeze(
          convert_to_dst_type(
              ForegroundMask(hsv_threshold={"S": "otsu"})(wsi), dst=wsi
          )[0]
      )
      mask_locations = np.vstack(mask.nonzero()).T
  
      # convert mask locations to image locations at level=0
      mask_ratio = self.wsi_reader.get_downsample_ratio(
          wsi_obj, self.mask_level
      )
      patch_ratio = self.wsi_reader.get_downsample_ratio(
          wsi_obj, patch_level
      )
      patch_size_0 = np.array(
          [p * patch_ratio for p in patch_size]
      )  # patch size at level 0
      patch_locations = np.round(
          (mask_locations + 0.5) * float(mask_ratio) - patch_size_0 // 2
      ).astype(int)
  
      # fill out samples with location and metadata
      sample[WSIPatchKeys.SIZE.value] = patch_size
      sample[WSIPatchKeys.LEVEL.value] = patch_level
      sample[ProbMapKeys.NAME.value] = os.path.basename(
          sample[CommonKeys.IMAGE]
      )
      sample[ProbMapKeys.COUNT.value] = len(patch_locations)
      sample[ProbMapKeys.SIZE.value] = mask.shape
      return [
          {
              **sample,
              WSIPatchKeys.LOCATION.value: np.array(loc),
              ProbMapKeys.LOCATION.value: mask_loc,
          }
          for loc, mask_loc in zip(patch_locations, mask_locations)
      ]
  
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 2 for calling the MaskedPatchWSIDataset obj's underlying member method code with example usage: obj._evaluate_patch_locations(sample) and returns: unknown