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: Compute distances from points to a line. This is adapted from
  https://github.com/MhLiao/DB.
  
  Args:
      xs (ndarray): The x coordinates of points of size :math:`(N, )`.
      ys (ndarray): The y coordinates of size :math:`(N, )`.
      pt1 (ndarray): The first point on the line of size :math:`(2, )`.
      pt2 (ndarray): The second point on the line of size :math:`(2, )`.
  
  Returns:
      ndarray: The distance matrix of size :math:`(N, )`.
docstr_tok: ["Compute","distances","from","points","to","a","line",".","This","is","adapted","from","https",":","\/\/github.com\/MhLiao\/DB",".","Args",":","xs","(","ndarray",")",":","The","x","coordinates","of","points","of","size",":","math",":","`","(","N",",",")","`",".","ys","(","ndarray",")",":","The","y","coordinates","of","size",":","math",":","`","(","N",",",")","`",".","pt1","(","ndarray",")",":","The","first","point","on","the","line","of","size",":","math",":","`","(","2",",",")","`",".","pt2","(","ndarray",")",":","The","second","point","on","the","line","of","size",":","math",":","`","(","2",",",")","`",".","Returns",":","ndarray",":","The","distance","matrix","of","size",":","math",":","`","(","N",",",")","`","."]
code: def _dist_points2line(
      xs: np.ndarray, ys: np.ndarray, pt1: np.ndarray, pt2: np.ndarray
  ) -> np.ndarray:
      """Compute distances from points to a line. This is adapted from
      https://github.com/MhLiao/DB.
  
      Args:
          xs (ndarray): The x coordinates of points of size :math:`(N, )`.
          ys (ndarray): The y coordinates of size :math:`(N, )`.
          pt1 (ndarray): The first point on the line of size :math:`(2, )`.
          pt2 (ndarray): The second point on the line of size :math:`(2, )`.
  
      Returns:
          ndarray: The distance matrix of size :math:`(N, )`.
      """
      # suppose a triangle with three edge abc with c=point_1 point_2
      # a^2
      a_square = np.square(xs - pt1[0]) + np.square(ys - pt1[1])
      # b^2
      b_square = np.square(xs - pt2[0]) + np.square(ys - pt2[1])
      # c^2
      c_square = np.square(pt1[0] - pt2[0]) + np.square(pt1[1] - pt2[1])
      # -cosC=(c^2-a^2-b^2)/2(ab)
      neg_cos_c = (c_square - a_square - b_square) / (
          np.finfo(np.float32).eps + 2 * np.sqrt(a_square * b_square)
      )
      # clip -cosC value to [-1, 1]
      neg_cos_c = np.clip(neg_cos_c, -1.0, 1.0)
      # sinC^2=1-cosC^2
      square_sin = 1 - np.square(neg_cos_c)
      square_sin = np.nan_to_num(square_sin)
      # distance=a*b*sinC/c=a*h/c=2*area/c
      result = np.sqrt(
          a_square
          * b_square
          * square_sin
          / (np.finfo(np.float32).eps + c_square)
      )
      # set result to minimum edge if C<pi/2
      result[neg_cos_c < 0] = np.sqrt(np.fmin(a_square, b_square))[
          neg_cos_c < 0
      ]
      return result
  
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 8 for calling the DBModuleLoss obj's underlying member method code with example usage: obj._dist_points2line(xs, ys, pt1, pt2) and returns: result