class_docstr: The class for implementing PSENet loss. This is partially adapted from
  https://github.com/whai362/PSENet.
  
  PSENet: `Shape Robust Text Detection with
  Progressive Scale Expansion Network <https://arxiv.org/abs/1806.02559>`_.
  
  Args:
      weight_text (float): The weight of text loss. Defaults to 0.7.
      weight_kernel (float): The weight of text kernel. Defaults to 0.3.
      loss_text (dict): Loss type for text. Defaults to
          dict('MaskedSquareDiceLoss').
      loss_kernel (dict): Loss type for kernel. Defaults to
          dict('MaskedSquareDiceLoss').
      ohem_ratio (int or float): The negative/positive ratio in ohem.
          Defaults to 3.
      reduction (str): The way to reduce the loss. Defaults to 'mean'.
          Options are 'mean' and 'sum'.
      kernel_sample_type (str): The way to sample kernel. Defaults to
          adaptive. Options are 'adaptive' and 'hard'.
      shrink_ratio (tuple): The ratio for shirinking text instances.
          Defaults to (1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4).
      max_shrink_dist (int or float): The maximum shrinking distance.
          Defaults to 20.
code: def __init__(
      self,
      weight_text: float = 0.7,
      weight_kernel: float = 0.3,
      loss_text: Dict = dict(type="MaskedSquareDiceLoss"),
      loss_kernel: Dict = dict(type="MaskedSquareDiceLoss"),
      ohem_ratio: Union[int, float] = 3,
      reduction: str = "mean",
      kernel_sample_type: str = "adaptive",
      shrink_ratio: Tuple[float] = (1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4),
      max_shrink_dist: Union[int, float] = 20,
  ) -> None:
      super().__init__()
      assert reduction in [
          "mean",
          "sum",
      ], "reduction must be either of ['mean','sum']"
      assert kernel_sample_type in [
          "adaptive",
          "hard",
      ], "kernel_sample_type must be either of ['hard', 'adaptive']"
      self.weight_text = weight_text
      self.weight_kernel = weight_kernel
      self.ohem_ratio = ohem_ratio
      self.reduction = reduction
      self.shrink_ratio = shrink_ratio
      self.kernel_sample_type = kernel_sample_type
      self.max_shrink_dist = max_shrink_dist
      self.loss_text = MODELS.build(loss_text)
      self.loss_kernel = MODELS.build(loss_kernel)
  
file_path: mmocr/mmocr/models/textdet/module_losses/pse_module_loss.py
imports: from typing import Dict, Sequence, Tuple, Union
  import torch
  import torch.nn.functional
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from .None import PANModuleLoss
label_desc: Use image node_id 1 to create a new PSEModuleLoss object from inherited base classes: PANModuleLoss with example: obj = PSEModuleLoss(weight_text, weight_kernel, loss_text, loss_kernel, ohem_ratio, reduction, kernel_sample_type, shrink_ratio, max_shrink_dist)