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.
docstr: Pad the masks to the right and bottom side to the target size and
  pack them into a batch.
  
  Args:
      mask (list[ndarray]): The masks to be padded.
      target_sz (tuple(int, int)): The target tensor of size
          :math:`(H, W)`.
  
  Returns:
      ndarray: A batch of padded mask.
docstr_tok: ["Pad","the","masks","to","the","right","and","bottom","side","to","the","target","size","and","pack","them","into","a","batch",".","Args",":","mask","(","list","[","ndarray","]",")",":","The","masks","to","be","padded",".","target_sz","(","tuple","(","int",",","int",")",")",":","The","target","tensor","of","size",":","math",":","`","(","H",",","W",")","`",".","Returns",":","ndarray",":","A","batch","of","padded","mask","."]
code: def _batch_pad(
      self, masks: List[ndarray], target_sz: Tuple[int, int]
  ) -> ndarray:
      """Pad the masks to the right and bottom side to the target size and
      pack them into a batch.
  
      Args:
          mask (list[ndarray]): The masks to be padded.
          target_sz (tuple(int, int)): The target tensor of size
              :math:`(H, W)`.
  
      Returns:
          ndarray: A batch of padded mask.
      """
      batch = []
      for mask in masks:
          # H x W
          mask_sz = mask.shape
          # left, top, right, bottom
          padding = (
              0,
              0,
              target_sz[1] - mask_sz[1],
              target_sz[0] - mask_sz[0],
          )
          padded_mask = impad(
              mask, padding=padding, padding_mode="constant", pad_val=0
          )
          batch.append(np.expand_dims(padded_mask, axis=0))
      return np.concatenate(batch)
  
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 2 for calling the TextSnakeModuleLoss obj's underlying member method code with example usage: obj._batch_pad(masks, target_sz) and returns: np