code: def tblr2bboxes(
      priors: Tensor,
      tblr: Tensor,
      normalizer: Union[Sequence[float], float] = 4.0,
      normalize_by_wh: bool = True,
      max_shape: Optional[
          Union[Sequence[int], Tensor, Sequence[Sequence[int]]]
      ] = None,
      clip_border: bool = True,
  ) -> Tensor:
      """Decode tblr outputs to prediction boxes.
  
      The process includes 3 steps: 1) De-normalize tblr coordinates by
      multiplying it with `normalizer`; 2) De-normalize tblr coordinates by the
      prior bbox width and height if `normalize_by_wh` is `True`; 3) Convert
      tblr (top, bottom, left, right) pair relative to the center of priors back
      to (xmin, ymin, xmax, ymax) coordinate.
  
      Args:
          priors (Tensor): Prior boxes in point form (x0, y0, x1, y1)
            Shape: (N,4) or (B, N, 4).
          tblr (Tensor): Coords of network output in tblr form
            Shape: (N, 4) or (B, N, 4).
          normalizer (Sequence[float] | float): Normalization parameter of
            encoded boxes. By list, it represents the normalization factors at
            tblr dims. By float, it is the unified normalization factor at all
            dims. Default: 4.0
          normalize_by_wh (bool): Whether the tblr coordinates have been
            normalized by the side length (wh) of prior bboxes.
          max_shape (Sequence[int] or torch.Tensor or Sequence[
              Sequence[int]],optional): Maximum bounds for boxes, specifies
              (H, W, C) or (H, W). If priors shape is (B, N, 4), then
              the max_shape should be a Sequence[Sequence[int]]
              and the length of max_shape should also be B.
          clip_border (bool, optional): Whether clip the objects outside the
              border of the image. Defaults to True.
  
      Return:
          encoded boxes (Tensor): Boxes with shape (N, 4) or (B, N, 4)
      """
      if not isinstance(normalizer, float):
          normalizer = torch.tensor(normalizer, device=priors.device)
          assert len(normalizer) == 4, "Normalizer must have length = 4"
      assert priors.size(0) == tblr.size(0)
      if priors.ndim == 3:
          assert priors.size(1) == tblr.size(1)
  
      loc_decode = tblr * normalizer
      prior_centers = (priors[..., 0:2] + priors[..., 2:4]) / 2
      if normalize_by_wh:
          wh = priors[..., 2:4] - priors[..., 0:2]
          w, h = torch.split(wh, 1, dim=-1)
          # Inplace operation with slice would failed for exporting to ONNX
          th = h * loc_decode[..., :2]  # tb
          tw = w * loc_decode[..., 2:]  # lr
          loc_decode = torch.cat([th, tw], dim=-1)
      # Cannot be exported using onnx when loc_decode.split(1, dim=-1)
      top, bottom, left, right = loc_decode.split((1, 1, 1, 1), dim=-1)
      xmin = prior_centers[..., 0].unsqueeze(-1) - left
      xmax = prior_centers[..., 0].unsqueeze(-1) + right
      ymin = prior_centers[..., 1].unsqueeze(-1) - top
      ymax = prior_centers[..., 1].unsqueeze(-1) + bottom
  
      bboxes = torch.cat((xmin, ymin, xmax, ymax), dim=-1)
  
      if clip_border and max_shape is not None:
          # clip bboxes with dynamic `min` and `max` for onnx
          if torch.onnx.is_in_onnx_export():
              from mmdet.core.export import dynamic_clip_for_onnx
  
              xmin, ymin, xmax, ymax = dynamic_clip_for_onnx(
                  xmin, ymin, xmax, ymax, max_shape
              )
              bboxes = torch.cat([xmin, ymin, xmax, ymax], dim=-1)
              return bboxes
          if not isinstance(max_shape, torch.Tensor):
              max_shape = priors.new_tensor(max_shape)
          max_shape = max_shape[..., :2].type_as(priors)
          if max_shape.ndim == 2:
              assert bboxes.ndim == 3
              assert max_shape.size(0) == bboxes.size(0)
  
          min_xy = priors.new_tensor(0)
          max_xy = (
              torch.cat([max_shape, max_shape], dim=-1)
              .flip(-1)
              .unsqueeze(-2)
          )
          bboxes = torch.where(bboxes < min_xy, min_xy, bboxes)
          bboxes = torch.where(bboxes > max_xy, max_xy, bboxes)
  
      return bboxes
  
file_path: mmdetection/mmdet/models/task_modules/coders/tblr_bbox_coder.py
imports: from typing import Optional, Sequence, Union
  import torch
  from torch import Tensor
  from mmdet.registry import TASK_UTILS
  from mmdet.structures.bbox import BaseBoxes, HorizontalBoxes, get_box_tensor
  from .base_bbox_coder import BaseBBoxCoder
label_desc: Use image node_id 2 for calling a global function with example usage: tblr2bboxes(priors, tblr, normalizer, normalize_by_wh, max_shape, clip_border) and returns: bboxes, bboxes