class_docstr: The post-processing transform for HoVerNet model to generate instance segmentation map.
  It generates an instance segmentation map as well as a dictionary containing centroids, bounding boxes, and contours
  for each instance.
  
  Args:
      activation: the activation layer to be applied on the input probability map.
          It can be "softmax" or "sigmoid" string, or any callable. Defaults to "softmax".
      mask_threshold: a float value to threshold to binarize probability map to generate mask.
      min_object_size: objects smaller than this size (in pixel) are removed. Defaults to 10.
      sobel_kernel_size: the size of the Sobel kernel used in :py:class:`GenerateInstanceBorder`. Defaults to 5.
      distance_smooth_fn: smoothing function for distance map.
          If not provided, :py:class:`monai.transforms.intensity.GaussianSmooth()` will be used.
      marker_threshold: a float value to threshold to binarize instance border map for markers.
          It turns uncertain area to 1 and other area to 0. Defaults to 0.4.
      marker_radius: the radius of the disk-shaped footprint used in `opening` of markers. Defaults to 2.
      marker_postprocess_fn: post-process function for watershed markers.
          If not provided, :py:class:`monai.transforms.post.FillHoles()` will be used.
      watershed_connectivity: `connectivity` argument of `skimage.segmentation.watershed`.
      min_num_points: minimum number of points to be considered as a contour. Defaults to 3.
      contour_level: an optional value for `skimage.measure.find_contours` to find contours in the array.
          If not provided, the level is set to `(max(image) + min(image)) / 2`.
      device: target device to put the output Tensor data.
class_docstr_tok: ["The","post-processing","transform","for","HoVerNet","model","to","generate","instance","segmentation","map",".","It","generates","an","instance","segmentation","map","as","well","as","a","dictionary","containing","centroids",",","bounding","boxes",",","and","contours","for","each","instance",".","Args",":","activation",":","the","activation","layer","to","be","applied","on","the","input","probability","map",".","It","can","be","``","softmax","''","or","``","sigmoid","''","string",",","or","any","callable",".","Defaults","to","``","softmax","''",".","mask_threshold",":","a","float","value","to","threshold","to","binarize","probability","map","to","generate","mask",".","min_object_size",":","objects","smaller","than","this","size","(","in","pixel",")","are","removed",".","Defaults","to","10.","sobel_kernel_size",":","the","size","of","the","Sobel","kernel","used","in",":","py",":","class",":","`","GenerateInstanceBorder","`",".","Defaults","to","5.","distance_smooth_fn",":","smoothing","function","for","distance","map",".","If","not","provided",",",":","py",":","class",":","`","monai.transforms.intensity.GaussianSmooth","(",")","`","will","be","used",".","marker_threshold",":","a","float","value","to","threshold","to","binarize","instance","border","map","for","markers",".","It","turns","uncertain","area","to","1","and","other","area","to","0",".","Defaults","to","0.4.","marker_radius",":","the","radius","of","the","disk-shaped","footprint","used","in","`","opening","`","of","markers",".","Defaults","to","2.","marker_postprocess_fn",":","post-process","function","for","watershed","markers",".","If","not","provided",",",":","py",":","class",":","`","monai.transforms.post.FillHoles","(",")","`","will","be","used",".","watershed_connectivity",":","`","connectivity","`","argument","of","`","skimage.segmentation.watershed","`",".","min_num_points",":","minimum","number","of","points","to","be","considered","as","a","contour",".","Defaults","to","3.","contour_level",":","an","optional","value","for","`","skimage.measure.find_contours","`","to","find","contours","in","the","array",".","If","not","provided",",","the","level","is","set","to","`","(","max","(","image",")","+","min","(","image",")",")","\/","2","`",".","device",":","target","device","to","put","the","output","Tensor","data","."]
docstr: post-process instance segmentation branches (NP and HV) to generate instance segmentation map.
  
  Args:
      nuclear_prediction: the output of NP (nuclear prediction) branch of HoVerNet model
      hover_map: the output of HV (hover map) branch of HoVerNet model
docstr_tok: ["post-process","instance","segmentation","branches","(","NP","and","HV",")","to","generate","instance","segmentation","map",".","Args",":","nuclear_prediction",":","the","output","of","NP","(","nuclear","prediction",")","branch","of","HoVerNet","model","hover_map",":","the","output","of","HV","(","hover","map",")","branch","of","HoVerNet","model"]
code: def __call__(  # type: ignore
      self,
      nuclear_prediction: NdarrayOrTensor,
      hover_map: NdarrayOrTensor,
  ) -> tuple[dict, NdarrayOrTensor]:
      """post-process instance segmentation branches (NP and HV) to generate instance segmentation map.
  
      Args:
          nuclear_prediction: the output of NP (nuclear prediction) branch of HoVerNet model
          hover_map: the output of HV (hover map) branch of HoVerNet model
      """
  
      # Process NP and HV branch using watershed algorithm
      watershed_mask = self.generate_watershed_mask(nuclear_prediction)
      instance_borders = self.generate_instance_border(
          watershed_mask, hover_map
      )
      distance_map = self.generate_distance_map(
          watershed_mask, instance_borders
      )
      watershed_markers = self.generate_watershed_markers(
          watershed_mask, instance_borders
      )
      instance_map = self.watershed(
          distance_map, watershed_mask, watershed_markers
      )
  
      # Create bounding boxes, contours and centroids
      instance_ids = set(np.unique(instance_map)) - {
          0
      }  # exclude background
      instance_info = {}
      for inst_id in instance_ids:
          instance_mask = instance_map == inst_id
          instance_bbox = BoundingRect()(instance_mask)
  
          instance_mask = instance_mask[
              :,
              instance_bbox[0][0] : instance_bbox[0][1],
              instance_bbox[0][2] : instance_bbox[0][3],
          ]
          offset = [instance_bbox[0][2], instance_bbox[0][0]]
          instance_contour = self.generate_instance_contour(
              FillHoles()(instance_mask), offset
          )
          if instance_contour is not None:
              instance_centroid = self.generate_instance_centroid(
                  instance_mask, offset
              )
              instance_info[inst_id] = {
                  "bounding_box": instance_bbox,
                  "centroid": instance_centroid,
                  "contour": instance_contour,
              }
      instance_map = convert_to_tensor(instance_map, device=self.device)
      return instance_info, instance_map
  
imports: from __future__ import annotations
  import warnings
  from typing import Callable, Sequence
  import numpy
  import torch
  from monai.config.type_definitions import DtypeLike, NdarrayOrTensor
  from monai.transforms import Activations, AsDiscrete, BoundingRect, FillHoles, GaussianSmooth, RemoveSmallObjects, SobelGradients
  from monai.transforms.transform import Transform
  from monai.transforms.utils_pytorch_numpy_unification import max, maximum, min, sum, unique
  from monai.utils import TransformBackends, convert_to_numpy, optional_import
  from monai.utils.misc import ensure_tuple_rep
  from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor
label_desc: Use image node_id 2 for calling the HoVerNetInstanceMapPostProcessing obj's underlying member method code with example usage: obj.__call__(nuclear_prediction, hover_map) and returns: instance_info,  instance_map