code: def legacy_bbox2delta(
      proposals: Tensor,
      gt: Tensor,
      means: Sequence[float] = (0.0, 0.0, 0.0, 0.0),
      stds: Sequence[float] = (1.0, 1.0, 1.0, 1.0),
  ) -> Tensor:
      """Compute deltas of proposals w.r.t. gt in the MMDet V1.x manner.
  
      We usually compute the deltas of x, y, w, h of proposals w.r.t ground
      truth bboxes to get regression target.
      This is the inverse function of `delta2bbox()`
  
      Args:
          proposals (Tensor): Boxes to be transformed, shape (N, ..., 4)
          gt (Tensor): Gt bboxes to be used as base, shape (N, ..., 4)
          means (Sequence[float]): Denormalizing means for delta coordinates
          stds (Sequence[float]): Denormalizing standard deviation for delta
              coordinates
  
      Returns:
          Tensor: deltas with shape (N, 4), where columns represent dx, dy,
              dw, dh.
      """
      assert proposals.size() == gt.size()
  
      proposals = proposals.float()
      gt = gt.float()
      px = (proposals[..., 0] + proposals[..., 2]) * 0.5
      py = (proposals[..., 1] + proposals[..., 3]) * 0.5
      pw = proposals[..., 2] - proposals[..., 0] + 1.0
      ph = proposals[..., 3] - proposals[..., 1] + 1.0
  
      gx = (gt[..., 0] + gt[..., 2]) * 0.5
      gy = (gt[..., 1] + gt[..., 3]) * 0.5
      gw = gt[..., 2] - gt[..., 0] + 1.0
      gh = gt[..., 3] - gt[..., 1] + 1.0
  
      dx = (gx - px) / pw
      dy = (gy - py) / ph
      dw = torch.log(gw / pw)
      dh = torch.log(gh / ph)
      deltas = torch.stack([dx, dy, dw, dh], dim=-1)
  
      means = deltas.new_tensor(means).unsqueeze(0)
      stds = deltas.new_tensor(stds).unsqueeze(0)
      deltas = deltas.sub_(means).div_(stds)
  
      return deltas
  
file_path: mmdetection/mmdet/models/task_modules/coders/legacy_delta_xywh_bbox_coder.py
imports: from typing import Optional, Sequence, Union
  import numpy
  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 1 for calling a global function with example usage: legacy_bbox2delta(proposals, gt, means, stds) and returns: deltas