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'.
docstr: Generate loss target from a data sample.
  
  Args:
      data_sample (TextDetDataSample): The data sample.
  
  Returns:
      tuple: A tuple of four tensors as the targets of one prediction.
docstr_tok: ["Generate","loss","target","from","a","data","sample",".","Args",":","data_sample","(","TextDetDataSample",")",":","The","data","sample",".","Returns",":","tuple",":","A","tuple","of","four","tensors","as","the","targets","of","one","prediction","."]
code: def _get_target_single(
      self, data_sample: TextDetDataSample
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Generate loss target from a data sample.
  
      Args:
          data_sample (TextDetDataSample): The data sample.
  
      Returns:
          tuple: A tuple of four tensors as the targets of one prediction.
      """
      gt_polygons = data_sample.gt_instances.polygons
      gt_ignored = data_sample.gt_instances.ignored
  
      gt_kernels = []
      for ratio in self.shrink_ratio:
          # TODO pass `gt_ignored` to `_generate_kernels`
          gt_kernel, _ = self._generate_kernels(
              data_sample.img_shape,
              gt_polygons,
              ratio,
              ignore_flags=None,
              max_shrink_dist=self.max_shrink_dist,
          )
          gt_kernels.append(gt_kernel)
      gt_polygons_ignored = data_sample.gt_instances[
          gt_ignored
      ].polygons
      gt_mask = self._generate_effective_mask(
          data_sample.img_shape, gt_polygons_ignored
      )
  
      gt_kernels = np.stack(gt_kernels, axis=0)
      gt_kernels = torch.from_numpy(gt_kernels).float()
      gt_mask = torch.from_numpy(gt_mask).float()
      return gt_kernels, gt_mask
  
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 4 for calling the PANModuleLoss obj's underlying member method code with example usage: obj._get_target_single(data_sample) and returns: gt_kernels,  gt_mask