code: def _box_diou_iou(
      boxes1: Tensor, boxes2: Tensor, eps: float = 1e-7
  ) -> Tuple[Tensor, Tensor]:
      iou = box_iou(boxes1, boxes2)
      lti = torch.min(boxes1[:, None, :2], boxes2[:, :2])
      rbi = torch.max(boxes1[:, None, 2:], boxes2[:, 2:])
      whi = _upcast(rbi - lti).clamp(min=0)  # [N,M,2]
      diagonal_distance_squared = (
          (whi[:, :, 0] ** 2) + (whi[:, :, 1] ** 2) + eps
      )
      # centers of boxes
      x_p = (boxes1[:, 0] + boxes1[:, 2]) / 2
      y_p = (boxes1[:, 1] + boxes1[:, 3]) / 2
      x_g = (boxes2[:, 0] + boxes2[:, 2]) / 2
      y_g = (boxes2[:, 1] + boxes2[:, 3]) / 2
      # The distance between boxes' centers squared.
      centers_distance_squared = (
          _upcast((x_p[:, None] - x_g[None, :])) ** 2
      ) + (_upcast((y_p[:, None] - y_g[None, :])) ** 2)
      # The distance IoU is the IoU penalized by a normalized
      # distance between boxes' centers squared.
      return (
          iou - (centers_distance_squared / diagonal_distance_squared),
          iou,
      )
  
imports: from typing import Tuple
  import torch
  import torchvision
  from torch import Tensor
  from torchvision.extension import _assert_has_ops
  from ..utils import _log_api_usage_once
  from ._box_convert import _box_cxcywh_to_xyxy, _box_xywh_to_xyxy, _box_xyxy_to_cxcywh, _box_xyxy_to_xywh
  from ._utils import _upcast
label_desc: Use image node_id 14 for calling a global function with example usage: _box_diou_iou(boxes1, boxes2, eps) and returns: unknown,  iou