class_docstr: The class for implementing TextSnake loss. This is partially adapted
  from https://github.com/princewang1994/TextSnake.pytorch.
  
  TextSnake: `A Flexible Representation for Detecting Text of Arbitrary
  Shapes <https://arxiv.org/abs/1807.01544>`_.
  
  Args:
      ohem_ratio (float): The negative/positive ratio in ohem.
      downsample_ratio (float): Downsample ratio. Defaults to 1.0. TODO:
          remove it.
      orientation_thr (float): The threshold for distinguishing between
          head edge and tail edge among the horizontal and vertical edges
          of a quadrangle.
      resample_step (float): The step of resampling.
      center_region_shrink_ratio (float): The shrink ratio of text center.
      loss_text (dict): The loss config used to calculate the text loss.
      loss_center (dict): The loss config used to calculate the center loss.
      loss_radius (dict): The loss config used to calculate the radius loss.
      loss_sin (dict): The loss config used to calculate the sin loss.
      loss_cos (dict): The loss config used to calculate the cos loss.
code: def __init__(
      self,
      ohem_ratio: float = 3.0,
      downsample_ratio: float = 1.0,
      orientation_thr: float = 2.0,
      resample_step: float = 4.0,
      center_region_shrink_ratio: float = 0.3,
      loss_text: Dict = dict(
          type="MaskedBalancedBCEWithLogitsLoss",
          fallback_negative_num=100,
          eps=1e-5,
      ),
      loss_center: Dict = dict(type="MaskedBCEWithLogitsLoss"),
      loss_radius: Dict = dict(type="MaskedSmoothL1Loss"),
      loss_sin: Dict = dict(type="MaskedSmoothL1Loss"),
      loss_cos: Dict = dict(type="MaskedSmoothL1Loss"),
  ) -> None:
      super().__init__()
      self.ohem_ratio = ohem_ratio
      self.downsample_ratio = downsample_ratio
      self.orientation_thr = orientation_thr
      self.resample_step = resample_step
      self.center_region_shrink_ratio = center_region_shrink_ratio
      self.eps = 1e-8
      self.loss_text = MODELS.build(loss_text)
      self.loss_center = MODELS.build(loss_center)
      self.loss_radius = MODELS.build(loss_radius)
      self.loss_sin = MODELS.build(loss_sin)
      self.loss_cos = MODELS.build(loss_cos)
  
imports: from typing import Dict, List, Sequence, Tuple
  import cv2
  import numpy
  import torch
  from mmcv.image import impad, imrescale
  from mmdet.models.utils import multi_apply
  from numpy import ndarray
  from numpy.linalg import norm
  from torch import Tensor
  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 TextSnakeModuleLoss object from inherited base classes: SegBasedModuleLoss with example: obj = TextSnakeModuleLoss(ohem_ratio, downsample_ratio, orientation_thr, resample_step, center_region_shrink_ratio, loss_text, loss_center, loss_radius, loss_sin, loss_cos)