class_docstr: DiceLoss normalized on each instance.
  Input:
      pred: (N, 1, H, W)
      gt: (N, 1, H, W)
      mask: (N, H, W)
  Note: This class assume that input tensors are on gpu,
      while cput computation is required to find union areas.
class_docstr_tok: ["DiceLoss","normalized","on","each","instance",".","Input",":","pred",":","(","N",",","1",",","H",",","W",")","gt",":","(","N",",","1",",","H",",","W",")","mask",":","(","N",",","H",",","W",")","Note",":","This","class","assume","that","input","tensors","are","on","gpu",",","while","cput","computation","is","required","to","find","union","areas","."]
docstr: Args:
      tensor_on_gpu: (N, 1, H, W)
      blur: Lambda. If exists, each instance will be blured using `blur`.
docstr_tok: ["Args",":","tensor_on_gpu",":","(","N",",","1",",","H",",","W",")","blur",":","Lambda",".","If","exists",",","each","instance","will","be","blured","using","`","blur","`","."]
code: def label(self, tensor_on_gpu, blur=None):
      """
      Args:
          tensor_on_gpu: (N, 1, H, W)
          blur: Lambda. If exists, each instance will be blured using `blur`.
      """
      tensor = tensor_on_gpu.cpu().detach().numpy()
  
      instance_maps = []
      instance_counts = []
      for batch_index in range(tensor_on_gpu.shape[0]):
          instance = tensor[batch_index]
          if blur is not None:
              instance = blur(instance)
          lable_map, instance_count = ndimage.label(instance[0])
          instance_count = min(self.max_regions, instance_count)
          instance_map = []
          for index in range(1, instance_count):
              instance = (
                  torch.from_numpy(lable_map == index)
                  .to(tensor_on_gpu.device)
                  .type(torch.float32)
              )
              instance_map.append(instance)
          instance_maps.append(instance_map)
      return instance_maps, instance_counts
  
imports: import torch
  import torch.nn
  import numpy
  import cv2
  from scipy import ndimage
label_desc: Use image node_id 2 for calling the InstanceDiceLoss obj's underlying member method code with example usage: obj.label(tensor_on_gpu, blur) and returns: instance_maps,  instance_counts