class_docstr: The class for implementing PANet loss. This was partially adapted from
  https://github.com/whai362/pan_pp.pytorch and
  https://github.com/WenmuZhou/PAN.pytorch.
  
  PANet: `Efficient and Accurate Arbitrary-
  Shaped Text Detection with Pixel Aggregation Network
  <https://arxiv.org/abs/1908.05900>`_.
  
  Args:
      loss_text (dict) The loss config for text map. Defaults to
          dict(type='MaskedSquareDiceLoss').
      loss_kernel (dict) The loss config for kernel map. Defaults to
          dict(type='MaskedSquareDiceLoss').
      loss_embedding (dict) The loss config for embedding map. Defaults to
          dict(type='PANEmbLossV1').
      weight_text (float): The weight of text loss. Defaults to 1.
      weight_kernel (float): The weight of kernel loss. Defaults to 0.5.
      weight_embedding (float): The weight of embedding loss.
          Defaults to 0.25.
      ohem_ratio (float): The negative/positive ratio in ohem. Defaults to 3.
      shrink_ratio (tuple[float]) : The ratio of shrinking kernel. Defaults
          to (1.0, 0.5).
      max_shrink_dist (int or float): The maximum shrinking distance.
          Defaults to 20.
      reduction (str): The way to reduce the loss. Available options are
          "mean" and "sum". Defaults to 'mean'.
code: def __init__(
      self,
      loss_text: Dict = dict(type="MaskedSquareDiceLoss"),
      loss_kernel: Dict = dict(type="MaskedSquareDiceLoss"),
      loss_embedding: Dict = dict(type="PANEmbLossV1"),
      weight_text: float = 1.0,
      weight_kernel: float = 0.5,
      weight_embedding: float = 0.25,
      ohem_ratio: Union[int, float] = 3,  # TODO Find a better name
      shrink_ratio: Sequence[Union[int, float]] = (1.0, 0.5),
      max_shrink_dist: Union[int, float] = 20,
      reduction: str = "mean",
  ) -> None:
      super().__init__()
      assert reduction in [
          "mean",
          "sum",
      ], "reduction must in ['mean','sum']"
      self.weight_text = weight_text
      self.weight_kernel = weight_kernel
      self.weight_embedding = weight_embedding
      self.shrink_ratio = shrink_ratio
      self.ohem_ratio = ohem_ratio
      self.reduction = reduction
      self.max_shrink_dist = max_shrink_dist
      self.loss_text = MODELS.build(loss_text)
      self.loss_kernel = MODELS.build(loss_kernel)
      self.loss_embedding = MODELS.build(loss_embedding)
  
imports: import warnings
  from typing import Dict, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
  from mmdet.models.utils import multi_apply
  from torch import nn
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from .seg_based_module_loss import SegBasedModuleLoss
label_desc: Use image node_id 1 to create a new PANModuleLoss object from inherited base classes: SegBasedModuleLoss with example: obj = PANModuleLoss(loss_text, loss_kernel, loss_embedding, weight_text, weight_kernel, weight_embedding, ohem_ratio, shrink_ratio, max_shrink_dist, reduction)