class_docstr: The class for implementing DRRG loss. This is partially adapted from
  https://github.com/GXYM/DRRG licensed under the MIT license.
  
  DRRG: `Deep Relational Reasoning Graph Network for Arbitrary Shape Text
  Detection <https://arxiv.org/abs/1908.05900>`_.
  
  Args:
      ohem_ratio (float): The negative/positive ratio in ohem. Defaults to
          3.0.
      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. Defaults to 2.0.
      resample_step (float): The step size for resampling the text center
          line. Defaults to 8.0.
      num_min_comps (int): The minimum number of text components, which
          should be larger than k_hop1 mentioned in paper. Defaults to 9.
      num_max_comps (int): The maximum number of text components. Defaults
          to 600.
      min_width (float): The minimum width of text components. Defaults to
          8.0.
      max_width (float): The maximum width of text components. Defaults to
          24.0.
      center_region_shrink_ratio (float): The shrink ratio of text center
          regions. Defaults to 0.3.
      comp_shrink_ratio (float): The shrink ratio of text components.
          Defaults to 1.0.
      comp_w_h_ratio (float): The width to height ratio of text components.
          Defaults to 0.3.
      min_rand_half_height(float): The minimum half-height of random text
          components. Defaults to 8.0.
      max_rand_half_height (float): The maximum half-height of random
          text components. Defaults to 24.0.
      jitter_level (float): The jitter level of text component geometric
          features. Defaults to 0.2.
      loss_text (dict): The loss config used to calculate the text loss.
          Defaults to ``dict(type='MaskedBalancedBCEWithLogitsLoss',
          fallback_negative_num=100, eps=1e-5)``.
      loss_center (dict): The loss config used to calculate the center loss.
          Defaults to ``dict(type='MaskedBCEWithLogitsLoss')``.
      loss_top (dict): The loss config used to calculate the top loss, which
          is a part of the height loss. Defaults to
          ``dict(type='SmoothL1Loss', reduction='none')``.
      loss_btm (dict): The loss config used to calculate the bottom loss,
          which is a part of the height loss. Defaults to
          ``dict(type='SmoothL1Loss', reduction='none')``.
      loss_sin (dict): The loss config used to calculate the sin loss.
          Defaults to ``dict(type='MaskedSmoothL1Loss')``.
      loss_cos (dict): The loss config used to calculate the cos loss.
          Defaults to ``dict(type='MaskedSmoothL1Loss')``.
      loss_gcn (dict): The loss config used to calculate the GCN loss.
          Defaults to ``dict(type='CrossEntropyLoss')``.
docstr: Generate loss target from a data sample.
  
  Args:
      data_sample (TextDetDataSample): The data sample.
  
  Returns:
      tuple: A tuple of 8 tensors as DRRG targets.
  
      - gt_text_mask (ndarray): The text region mask.
      - gt_center_region_mask (ndarray): The text center region mask.
      - gt_mask (ndarray): The effective mask.
      - gt_top_height_map (ndarray): The map on which the distance from
        points to top side lines will be drawn for each pixel in text
        center regions.
      - gt_bot_height_map (ndarray): The map on which the distance from
        points to bottom side lines will be drawn for each pixel in text
        center regions.
      - gt_sin_map (ndarray): The sin(theta) map where theta is the angle
        between vector (top point - bottom point) and vector (1, 0).
      - gt_cos_map (ndarray): The cos(theta) map where theta is the angle
        between vector (top point - bottom point) and vector (1, 0).
      - gt_comp_attribs (ndarray): The padded text component attributes
        of a fixed size. Shape: (num_component, 8).
docstr_tok: ["Generate","loss","target","from","a","data","sample",".","Args",":","data_sample","(","TextDetDataSample",")",":","The","data","sample",".","Returns",":","tuple",":","A","tuple","of","8","tensors","as","DRRG","targets",".","-","gt_text_mask","(","ndarray",")",":","The","text","region","mask",".","-","gt_center_region_mask","(","ndarray",")",":","The","text","center","region","mask",".","-","gt_mask","(","ndarray",")",":","The","effective","mask",".","-","gt_top_height_map","(","ndarray",")",":","The","map","on","which","the","distance","from","points","to","top","side","lines","will","be","drawn","for","each","pixel","in","text","center","regions",".","-","gt_bot_height_map","(","ndarray",")",":","The","map","on","which","the","distance","from","points","to","bottom","side","lines","will","be","drawn","for","each","pixel","in","text","center","regions",".","-","gt_sin_map","(","ndarray",")",":","The","sin","(","theta",")","map","where","theta","is","the","angle","between","vector","(","top","point","-","bottom","point",")","and","vector","(","1",",","0",")",".","-","gt_cos_map","(","ndarray",")",":","The","cos","(","theta",")","map","where","theta","is","the","angle","between","vector","(","top","point","-","bottom","point",")","and","vector","(","1",",","0",")",".","-","gt_comp_attribs","(","ndarray",")",":","The","padded","text","component","attributes","of","a","fixed","size",".","Shape",":","(","num_component",",","8",")","."]
code: def _get_target_single(self, data_sample: TextDetDataSample) -> Tuple:
      """Generate loss target from a data sample.
  
      Args:
          data_sample (TextDetDataSample): The data sample.
  
      Returns:
          tuple: A tuple of 8 tensors as DRRG targets.
  
          - gt_text_mask (ndarray): The text region mask.
          - gt_center_region_mask (ndarray): The text center region mask.
          - gt_mask (ndarray): The effective mask.
          - gt_top_height_map (ndarray): The map on which the distance from
            points to top side lines will be drawn for each pixel in text
            center regions.
          - gt_bot_height_map (ndarray): The map on which the distance from
            points to bottom side lines will be drawn for each pixel in text
            center regions.
          - gt_sin_map (ndarray): The sin(theta) map where theta is the angle
            between vector (top point - bottom point) and vector (1, 0).
          - gt_cos_map (ndarray): The cos(theta) map where theta is the angle
            between vector (top point - bottom point) and vector (1, 0).
          - gt_comp_attribs (ndarray): The padded text component attributes
            of a fixed size. Shape: (num_component, 8).
      """
  
      gt_instances = data_sample.gt_instances
      ignore_flags = gt_instances.ignored
  
      polygons = gt_instances[~ignore_flags].polygons
      ignored_polygons = gt_instances[ignore_flags].polygons
      h, w = data_sample.img_shape
  
      gt_text_mask = self._generate_text_region_mask((h, w), polygons)
      gt_mask = self._generate_effective_mask((h, w), ignored_polygons)
      (
          center_lines,
          gt_center_region_mask,
          gt_top_height_map,
          gt_bot_height_map,
          gt_sin_map,
          gt_cos_map,
      ) = self._generate_center_mask_attrib_maps((h, w), polygons)
  
      gt_comp_attribs = self._generate_comp_attribs(
          center_lines,
          gt_text_mask,
          gt_center_region_mask,
          gt_top_height_map,
          gt_bot_height_map,
          gt_sin_map,
          gt_cos_map,
      )
  
      return (
          gt_text_mask,
          gt_center_region_mask,
          gt_mask,
          gt_top_height_map,
          gt_bot_height_map,
          gt_sin_map,
          gt_cos_map,
          gt_comp_attribs,
      )
  
imports: from typing import Dict, List, Sequence, Tuple
  import cv2
  import numpy
  import torch
  from mmcv.image import 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 mmocr.utils import check_argument
  from .textsnake_module_loss import TextSnakeModuleLoss
label_desc: Use image node_id 4 for calling the DRRGModuleLoss obj's underlying member method code with example usage: obj._get_target_single(data_sample) and returns: gt_text_mask,  gt_center_region_mask,  gt_mask,  gt_top_height_map,  gt_bot_height_map,  gt_sin_map,  gt_cos_map,  gt_comp_attribs