class_docstr: SDMGR Head.
  
  Args:
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`.
      num_classes (int): Number of class labels. Defaults to 26.
      visual_dim (int): Dimension of visual features :math:`E`. Defaults to
          64.
      fusion_dim (int): Dimension of fusion layer. Defaults to 1024.
      node_input (int): Dimension of raw node embedding. Defaults to 32.
      node_embed (int): Dimension of node embedding. Defaults to 256.
      edge_input (int): Dimension of raw edge embedding. Defaults to 5.
      edge_embed (int): Dimension of edge embedding. Defaults to 256.
      num_gnn (int): Number of GNN layers. Defaults to 2.
      bidirectional (bool): Whether to use bidirectional RNN to embed nodes.
          Defaults to False.
      relation_norm (float): Norm to map value from one range to another.=
          Defaults to 10.
      module_loss (dict): Module Loss config. Defaults to
          ``dict(type='SDMGRModuleLoss')``.
      postprocessor (dict): Postprocessor config. Defaults to
          ``dict(type='SDMGRPostProcessor')``.
      init_cfg (dict or list[dict], optional): Initialization configs.
docstr: Compute the relations between every two boxes for each datasample,
  then return the concatenated relations.
docstr_tok: ["Compute","the","relations","between","every","two","boxes","for","each","datasample",",","then","return","the","concatenated","relations","."]
code: def compute_relations(
      self, data_samples: List[KIEDataSample]
  ) -> Tensor:
      """Compute the relations between every two boxes for each datasample,
      then return the concatenated relations."""
  
      relations = []
      for data_sample in data_samples:
          bboxes = data_sample.gt_instances.bboxes
          x1, y1 = bboxes[:, 0:1], bboxes[:, 1:2]
          x2, y2 = bboxes[:, 2:3], bboxes[:, 3:4]
          w, h = torch.clamp(x2 - x1 + 1, min=1), torch.clamp(
              y2 - y1 + 1, min=1
          )
          dx = (x1.t() - x1) / self.relation_norm
          dy = (y1.t() - y1) / self.relation_norm
          xhh, xwh = h.T / h, w.T / h
          whs = w / h + torch.zeros_like(xhh)
          relation = torch.stack([dx, dy, whs, xhh, xwh], -1).float()
          relations.append(relation)
      return relations
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  from mmengine.model import BaseModule
  from torch import Tensor, nn
  from torch.nn import functional
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.registry import MODELS, TASK_UTILS
  from mmocr.structures import KIEDataSample
label_desc: Use image node_id 6 for calling the SDMGRHead obj's underlying member method code with example usage: obj.compute_relations(data_samples) and returns: relations