class_docstr: The class for DRRG head: `Deep Relational Reasoning Graph Network for
  Arbitrary Shape Text Detection <https://arxiv.org/abs/2003.07493>`_.
  
  Args:
      in_channels (int): The number of input channels.
      k_at_hops (tuple(int)): The number of i-hop neighbors, i = 1, 2.
          Defaults to (8, 4).
      num_adjacent_linkages (int): The number of linkages when constructing
          adjacent matrix. Defaults to 3.
      node_geo_feat_len (int): The length of embedded geometric feature
          vector of a component. Defaults to 120.
      pooling_scale (float): The spatial scale of rotated RoI-Align. Defaults
          to 1.0.
      pooling_output_size (tuple(int)): The output size of RRoI-Aligning.
          Defaults to (4, 3).
      nms_thr (float): The locality-aware NMS threshold of text components.
          Defaults to 0.3.
      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.
      comp_shrink_ratio (float): The shrink ratio of text components.
          Defaults to 1.03.
      comp_ratio (float): The reciprocal of aspect ratio of text components.
          Defaults to 0.4.
      comp_score_thr (float): The score threshold of text components.
          Defaults to 0.3.
      text_region_thr (float): The threshold for text region probability map.
          Defaults to 0.2.
      center_region_thr (float): The threshold for text center region
          probability map. Defaults to 0.2.
      center_region_area_thr (int): The threshold for filtering small-sized
          text center region. Defaults to 50.
      local_graph_thr (float): The threshold to filter identical local
          graphs. Defaults to 0.7.
      module_loss (dict): The config of loss that DRRGHead uses. Defaults to
          ``dict(type='DRRGModuleLoss')``.
      postprocessor (dict): Config of postprocessor for Drrg. Defaults to
          ``dict(type='DrrgPostProcessor', link_thr=0.85)``.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to ``dict(type='Normal',
          override=dict(name='out_conv'), mean=0, std=0.01)``.
docstr: Loss function.
  
  Args:
      inputs (Tensor): Shape of :math:`(N, C, H, W)`.
      data_samples (List[TextDetDataSample]): List of data samples.
  
  Returns:
      tuple(pred_maps, gcn_pred, gt_labels):
  
      - pred_maps (Tensor): Prediction map with shape
          :math:`(N, 6, H, W)`.
      - gcn_pred (Tensor): Prediction from GCN module, with
          shape :math:`(N, 2)`.
      - gt_labels (Tensor): Ground-truth label of shape
          :math:`(m, n)` where :math:`m * n = N`.
docstr_tok: ["Loss","function",".","Args",":","inputs","(","Tensor",")",":","Shape","of",":","math",":","`","(","N",",","C",",","H",",","W",")","`",".","data_samples","(","List","[","TextDetDataSample","]",")",":","List","of","data","samples",".","Returns",":","tuple","(","pred_maps",",","gcn_pred",",","gt_labels",")",":","-","pred_maps","(","Tensor",")",":","Prediction","map","with","shape",":","math",":","`","(","N",",","6",",","H",",","W",")","`",".","-","gcn_pred","(","Tensor",")",":","Prediction","from","GCN","module",",","with","shape",":","math",":","`","(","N",",","2",")","`",".","-","gt_labels","(","Tensor",")",":","Ground-truth","label","of","shape",":","math",":","`","(","m",",","n",")","`","where",":","math",":","`","m","*","n","=","N","`","."]
code: def loss(
      self, inputs: torch.Tensor, data_samples: List[TextDetDataSample]
  ) -> Tuple[Tensor, Tensor, Tensor]:
      """Loss function.
  
      Args:
          inputs (Tensor): Shape of :math:`(N, C, H, W)`.
          data_samples (List[TextDetDataSample]): List of data samples.
  
      Returns:
          tuple(pred_maps, gcn_pred, gt_labels):
  
          - pred_maps (Tensor): Prediction map with shape
              :math:`(N, 6, H, W)`.
          - gcn_pred (Tensor): Prediction from GCN module, with
              shape :math:`(N, 2)`.
          - gt_labels (Tensor): Ground-truth label of shape
              :math:`(m, n)` where :math:`m * n = N`.
      """
      targets = self.module_loss.get_targets(data_samples)
      gt_comp_attribs = targets[-1]
  
      pred_maps = self.out_conv(inputs)
      feat_maps = torch.cat([inputs, pred_maps], dim=1)
      (
          node_feats,
          adjacent_matrices,
          knn_inds,
          gt_labels,
      ) = self.graph_train(feat_maps, np.stack(gt_comp_attribs))
  
      gcn_pred = self.gcn(node_feats, adjacent_matrices, knn_inds)
  
      return self.module_loss(
          (pred_maps, gcn_pred, gt_labels), data_samples
      )
  
imports: from typing import Dict, List, Optional, Sequence, Tuple, Union
  import cv2
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.ops import RoIAlignRotated
  from mmengine.model import BaseModule
  from numpy import ndarray
  from torch import Tensor
  from torch.nn import init
  from mmocr.models.textdet.heads import BaseTextDetHead
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from mmocr.utils import fill_hole
label_desc: Use image node_id 2 for calling the DRRGHead obj's underlying member method code with example usage: obj.loss(inputs, data_samples) and returns: self