class_docstr: Generate instance type and probability for each instance.
class_docstr_tok: ["Generate","instance","type","and","probability","for","each","instance","."]
docstr: Args:
      type_pred: pixel-level type prediction map after activation function.
      seg_pred: pixel-level segmentation prediction map after activation function.
      bbox: bounding box coordinates of the instance, shape is [channel, 2 * spatial dims].
      instance_id: get instance type from specified instance id.
docstr_tok: ["Args",":","type_pred",":","pixel-level","type","prediction","map","after","activation","function",".","seg_pred",":","pixel-level","segmentation","prediction","map","after","activation","function",".","bbox",":","bounding","box","coordinates","of","the","instance",",","shape","is","[","channel",",","2","*","spatial","dims","]",".","instance_id",":","get","instance","type","from","specified","instance","id","."]
code: def __call__(  # type: ignore
      self,
      type_pred: NdarrayOrTensor,
      seg_pred: NdarrayOrTensor,
      bbox: np.ndarray,
      instance_id: int,
  ) -> tuple[int, float]:
      """
      Args:
          type_pred: pixel-level type prediction map after activation function.
          seg_pred: pixel-level segmentation prediction map after activation function.
          bbox: bounding box coordinates of the instance, shape is [channel, 2 * spatial dims].
          instance_id: get instance type from specified instance id.
      """
  
      rmin, rmax, cmin, cmax = bbox.flatten()
      seg_map_crop = seg_pred[0, rmin:rmax, cmin:cmax]
      type_map_crop = type_pred[0, rmin:rmax, cmin:cmax]
  
      seg_map_crop = convert_to_dst_type(
          seg_map_crop == instance_id, type_map_crop, dtype=bool
      )[0]
  
      inst_type = type_map_crop[seg_map_crop]  # type: ignore
      type_list, type_pixels = unique(inst_type, return_counts=True)
      type_list = list(zip(type_list, type_pixels))
      type_list = sorted(type_list, key=lambda x: x[1], reverse=True)
      inst_type = type_list[0][0]
      if inst_type == 0:  # ! pick the 2nd most dominant if exist
          if len(type_list) > 1:
              inst_type = type_list[1][0]
      type_dict = {v[0]: v[1] for v in type_list}
      type_prob = type_dict[inst_type] / (sum(seg_map_crop) + 1.0e-6)
  
      return (int(inst_type), float(type_prob))
  
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 1 for calling the GenerateInstanceType obj's underlying member method code with example usage: obj.__call__(type_pred, seg_pred, bbox, instance_id) and returns: int,  float