class_docstr: The class for implementing DBNet loss.
  
  This is partially adapted from https://github.com/MhLiao/DB.
  
  Args:
      loss_prob (dict): The loss config for probability map. Defaults to
          dict(type='MaskedBalancedBCEWithLogitsLoss').
      loss_thr (dict): The loss config for threshold map. Defaults to
          dict(type='MaskedSmoothL1Loss', beta=0).
      loss_db (dict): The loss config for binary map. Defaults to
          dict(type='MaskedDiceLoss').
      weight_prob (float): The weight of probability map loss.
          Denoted as :math:`\alpha` in paper. Defaults to 5.
      weight_thr (float): The weight of threshold map loss.
          Denoted as :math:`\beta` in paper. Defaults to 10.
      shrink_ratio (float): The ratio of shrunk text region. Defaults to 0.4.
      thr_min (float): The minimum threshold map value. Defaults to 0.3.
      thr_max (float): The maximum threshold map value. Defaults to 0.7.
      min_sidelength (int or float): The minimum sidelength of the
          minimum rotated rectangle around any text region. Defaults to 8.
docstr: Generate threshold map.
  
  Args:
      img_size (tuple(int)): The image size (h, w)
      polygons (Sequence[ndarray]): 2-d array, representing all the
          polygons of the text region.
  
  Returns:
      tuple:
  
      - thr_map (ndarray): The generated threshold map.
      - thr_mask (ndarray): The effective mask of threshold map.
docstr_tok: ["Generate","threshold","map",".","Args",":","img_size","(","tuple","(","int",")",")",":","The","image","size","(","h",",","w",")","polygons","(","Sequence","[","ndarray","]",")",":","2-d","array",",","representing","all","the","polygons","of","the","text","region",".","Returns",":","tuple",":","-","thr_map","(","ndarray",")",":","The","generated","threshold","map",".","-","thr_mask","(","ndarray",")",":","The","effective","mask","of","threshold","map","."]
code: def _generate_thr_map(
      self, img_size: Tuple[int, int], polygons: ArrayLike
  ) -> np.ndarray:
      """Generate threshold map.
  
      Args:
          img_size (tuple(int)): The image size (h, w)
          polygons (Sequence[ndarray]): 2-d array, representing all the
              polygons of the text region.
  
      Returns:
          tuple:
  
          - thr_map (ndarray): The generated threshold map.
          - thr_mask (ndarray): The effective mask of threshold map.
      """
      thr_map = np.zeros(img_size, dtype=np.float32)
      thr_mask = np.zeros(img_size, dtype=np.uint8)
  
      for polygon in polygons:
          self._draw_border_map(polygon, thr_map, mask=thr_mask)
      thr_map = thr_map * (self.thr_max - self.thr_min) + self.thr_min
  
      return thr_map, thr_mask
  
imports: from typing import Dict, List, Sequence, Tuple, Union
  import cv2
  import numpy
  import torch
  from mmdet.models.utils import multi_apply
  from shapely.geometry import Polygon
  from torch import Tensor
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from mmocr.utils import offset_polygon
  from mmocr.utils.typing_utils import ArrayLike
  from .seg_based_module_loss import SegBasedModuleLoss
label_desc: Use image node_id 4 for calling the DBModuleLoss obj's underlying member method code with example usage: obj._generate_thr_map(img_size, polygons) and returns: thr_map,  thr_mask