class_docstr: Generate instance border by hover map. The more parts of the image that cannot be identified as foreground areas,
  the larger the grey scale value. The grey value of the instance's border will be larger.
  
  Args:
      kernel_size: the size of the Sobel kernel. Defaults to 5.
      dtype: target data type to convert to. Defaults to np.float32.
  
  
  Raises:
      ValueError: when the `mask` shape is not [1, H, W].
      ValueError: when the `hover_map` shape is not [2, H, W].
class_docstr_tok: ["Generate","instance","border","by","hover","map",".","The","more","parts","of","the","image","that","can","not","be","identified","as","foreground","areas",",","the","larger","the","grey","scale","value",".","The","grey","value","of","the","instance","'s","border","will","be","larger",".","Args",":","kernel_size",":","the","size","of","the","Sobel","kernel",".","Defaults","to","5.","dtype",":","target","data","type","to","convert","to",".","Defaults","to","np.float32",".","Raises",":","ValueError",":","when","the","`","mask","`","shape","is","not","[","1",",","H",",","W","]",".","ValueError",":","when","the","`","hover_map","`","shape","is","not","[","2",",","H",",","W","]","."]
docstr: Args:
      mask: binary segmentation map, the output of :py:class:`GenerateWatershedMask`.
          Shape must be [1, H, W] or [H, W].
      hover_map:  horizontal and vertical distances of nuclear pixels to their centres of mass. Shape must be [2, H, W].
          The first and second channel represent the horizontal and vertical maps respectively. For more details refer
          to papers: https://arxiv.org/abs/1812.06499.
docstr_tok: ["Args",":","mask",":","binary","segmentation","map",",","the","output","of",":","py",":","class",":","`","GenerateWatershedMask","`",".","Shape","must","be","[","1",",","H",",","W","]","or","[","H",",","W","]",".","hover_map",":","horizontal","and","vertical","distances","of","nuclear","pixels","to","their","centres","of","mass",".","Shape","must","be","[","2",",","H",",","W","]",".","The","first","and","second","channel","represent","the","horizontal","and","vertical","maps","respectively",".","For","more","details","refer","to","papers",":","https",":","\/\/arxiv.org\/abs\/1812.06499","."]
code: def __call__(self, mask: NdarrayOrTensor, hover_map: NdarrayOrTensor) -> NdarrayOrTensor:  # type: ignore
      """
      Args:
          mask: binary segmentation map, the output of :py:class:`GenerateWatershedMask`.
              Shape must be [1, H, W] or [H, W].
          hover_map:  horizontal and vertical distances of nuclear pixels to their centres of mass. Shape must be [2, H, W].
              The first and second channel represent the horizontal and vertical maps respectively. For more details refer
              to papers: https://arxiv.org/abs/1812.06499.
      """
      if len(hover_map.shape) != 3:
          raise ValueError(
              f"The hover map should have the shape of [C, H, W], but got {hover_map.shape}."
          )
      if len(mask.shape) == 3:
          if mask.shape[0] != 1:
              raise ValueError(
                  f"The mask should have only one channel, but got {mask.shape[0]}."
              )
      elif len(mask.shape) == 2:
          mask = mask[None]
      else:
          raise ValueError(
              f"The mask should have the shape of [1, H, W] or [H, W], but got {mask.shape}."
          )
      if hover_map.shape[0] != 2:
          raise ValueError(
              f"Suppose the hover map only has two channels, but got {hover_map.shape[0]}"
          )
  
      hover_h = hover_map[0:1, ...]
      hover_v = hover_map[1:2, ...]
  
      hover_h_min, hover_h_max = min(hover_h), max(hover_h)
      hover_v_min, hover_v_max = min(hover_v), max(hover_v)
      if (hover_h_max - hover_h_min) == 0 or (
          hover_v_max - hover_v_min
      ) == 0:
          raise ValueError(
              "Not a valid hover map, please check your input"
          )
      hover_h = (hover_h - hover_h_min) / (hover_h_max - hover_h_min)
      hover_v = (hover_v - hover_v_min) / (hover_v_max - hover_v_min)
      sobelh = self.sobel_gradient(hover_h)[1, ...]
      sobelv = self.sobel_gradient(hover_v)[0, ...]
      sobelh_min, sobelh_max = min(sobelh), max(sobelh)
      sobelv_min, sobelv_max = min(sobelv), max(sobelv)
      if (sobelh_max - sobelh_min) == 0 or (
          sobelv_max - sobelv_min
      ) == 0:
          raise ValueError("Not a valid sobel gradient map")
      sobelh = 1 - (sobelh - sobelh_min) / (sobelh_max - sobelh_min)
      sobelv = 1 - (sobelv - sobelv_min) / (sobelv_max - sobelv_min)
  
      # combine the h & v values using max
      overall = maximum(sobelh, sobelv)
      overall = overall - (1 - mask)
      overall[overall < 0] = 0
  
      return convert_to_dst_type(overall, mask, dtype=self.dtype)[0]
  
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 GenerateInstanceBorder obj's underlying member method code with example usage: obj.__call__(mask, hover_map) and returns: convert_to_dst_type