class_docstr: Computes Distance Intersection Over Union (`DIoU`_).
  
  As input to ``forward`` and ``update`` the metric accepts the following input:
  
  - ``preds`` (:class:`~List`): A list consisting of dictionaries each containing the key-values
    (each dictionary corresponds to a single image). Parameters that should be provided per dict:
  
      - ``boxes`` (:class:`~torch.Tensor`): float tensor of shape ``(num_boxes, 4)`` containing ``num_boxes``
        detection boxes of the format specified in the constructor.
        By default, this method expects ``(xmin, ymin, xmax, ymax)`` in absolute image coordinates.
      - ``labels`` (:class:`~torch.Tensor`): integer tensor of shape ``(num_boxes)`` containing 0-indexed detection
        classes for the boxes.
  
  - ``target`` (:class:`~List`): A list consisting of dictionaries each containing the key-values
    (each dictionary corresponds to a single image). Parameters that should be provided per dict:
  
      - ``boxes`` (:class:`~torch.Tensor`): float tensor of shape ``(num_boxes, 4)`` containing ``num_boxes`` ground
        truth boxes of the format specified in the constructor.
        By default, this method expects ``(xmin, ymin, xmax, ymax)`` in absolute image coordinates.
      - ``labels`` (:class:`~torch.Tensor`): integer tensor of shape ``(num_boxes)`` containing 0-indexed ground truth
        classes for the boxes.
  
  As output of ``forward`` and ``compute`` the metric returns the following output:
  
  - ``diou_dict``: A dictionary containing the following key-values:
  
      - diou: (:class:`~torch.Tensor`) with overall diou value over all classes and samples.
      - diou/cl_{cl}: (:class:`~torch.Tensor`), if argument ``class_metrics=True``
  
  Args:
      box_format:
          Input format of given boxes. Supported formats are ``['xyxy', 'xywh', 'cxcywh']``.
      iou_thresholds:
          Optional IoU thresholds for evaluation. If set to `None` the threshold is ignored.
      class_metrics:
          Option to enable per-class metrics for IoU. Has a performance impact.
      respect_labels:
          Ignore values from boxes that do not have the same label as the ground truth box. Else will compute Iou
          between all pairs of boxes.
      kwargs:
          Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Example:
      >>> import torch
      >>> from torchmetrics.detection import DistanceIntersectionOverUnion
      >>> preds = [
      ...    {
      ...        "boxes": torch.tensor([[296.55, 93.96, 314.97, 152.79], [298.55, 98.96, 314.97, 151.79]]),
      ...        "scores": torch.tensor([0.236, 0.56]),
      ...        "labels": torch.tensor([4, 5]),
      ...    }
      ... ]
      >>> target = [
      ...    {
      ...        "boxes": torch.tensor([[300.00, 100.00, 315.00, 150.00]]),
      ...        "labels": torch.tensor([5]),
      ...    }
      ... ]
      >>> metric = DistanceIntersectionOverUnion()
      >>> metric(preds, target)
      {'diou': tensor(0.8611)}
  
  Raises:
      ModuleNotFoundError:
          If torchvision is not installed with version 0.13.0 or newer.
class_docstr_tok: ["Computes","Distance","Intersection","Over","Union","(","`","DIoU","`","_",")",".","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input",":","-","``","preds","``","(",":","class",":","`","~List","`",")",":","A","list","consisting","of","dictionaries","each","containing","the","key-values","(","each","dictionary","corresponds","to","a","single","image",")",".","Parameters","that","should","be","provided","per","dict",":","-","``","boxes","``","(",":","class",":","`","~torch.Tensor","`",")",":","float","tensor","of","shape","``","(","num_boxes",",","4",")","``","containing","``","num_boxes","``","detection","boxes","of","the","format","specified","in","the","constructor",".","By","default",",","this","method","expects","``","(","xmin",",","ymin",",","xmax",",","ymax",")","``","in","absolute","image","coordinates",".","-","``","labels","``","(",":","class",":","`","~torch.Tensor","`",")",":","integer","tensor","of","shape","``","(","num_boxes",")","``","containing","0-indexed","detection","classes","for","the","boxes",".","-","``","target","``","(",":","class",":","`","~List","`",")",":","A","list","consisting","of","dictionaries","each","containing","the","key-values","(","each","dictionary","corresponds","to","a","single","image",")",".","Parameters","that","should","be","provided","per","dict",":","-","``","boxes","``","(",":","class",":","`","~torch.Tensor","`",")",":","float","tensor","of","shape","``","(","num_boxes",",","4",")","``","containing","``","num_boxes","``","ground","truth","boxes","of","the","format","specified","in","the","constructor",".","By","default",",","this","method","expects","``","(","xmin",",","ymin",",","xmax",",","ymax",")","``","in","absolute","image","coordinates",".","-","``","labels","``","(",":","class",":","`","~torch.Tensor","`",")",":","integer","tensor","of","shape","``","(","num_boxes",")","``","containing","0-indexed","ground","truth","classes","for","the","boxes",".","As","output","of","``","forward","``","and","``","compute","``","the","metric","returns","the","following","output",":","-","``","diou_dict","``",":","A","dictionary","containing","the","following","key-values",":","-","diou",":","(",":","class",":","`","~torch.Tensor","`",")","with","overall","diou","value","over","all","classes","and","samples",".","-","diou\/cl_","{","cl","}",":","(",":","class",":","`","~torch.Tensor","`",")",",","if","argument","``","class_metrics=True","``","Args",":","box_format",":","Input","format","of","given","boxes",".","Supported","formats","are","``","[","'xyxy","'",",","'xywh","'",",","'cxcywh","'","]","``",".","iou_thresholds",":","Optional","IoU","thresholds","for","evaluation",".","If","set","to","`","None","`","the","threshold","is","ignored",".","class_metrics",":","Option","to","enable","per-class","metrics","for","IoU",".","Has","a","performance","impact",".","respect_labels",":","Ignore","values","from","boxes","that","do","not","have","the","same","label","as","the","ground","truth","box",".","Else","will","compute","Iou","between","all","pairs","of","boxes",".","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","Example",":",">",">",">","import","torch",">",">",">","from","torchmetrics.detection","import","DistanceIntersectionOverUnion",">",">",">","preds","=","[","...","{","...","``","boxes","''",":","torch.tensor","(","[","[","296.55",",","93.96",",","314.97",",","152.79","]",",","[","298.55",",","98.96",",","314.97",",","151.79","]","]",")",",","...","``","scores","''",":","torch.tensor","(","[","0.236",",","0.56","]",")",",","...","``","labels","''",":","torch.tensor","(","[","4",",","5","]",")",",","...","}","...","]",">",">",">","target","=","[","...","{","...","``","boxes","''",":","torch.tensor","(","[","[","300.00",",","100.00",",","315.00",",","150.00","]","]",")",",","...","``","labels","''",":","torch.tensor","(","[","5","]",")",",","...","}","...","]",">",">",">","metric","=","DistanceIntersectionOverUnion","(",")",">",">",">","metric","(","preds",",","target",")","{","'diou","'",":","tensor","(","0.8611",")","}","Raises",":","ModuleNotFoundError",":","If","torchvision","is","not","installed","with","version","0.13.0","or","newer","."]
code: def __init__(
      self,
      box_format: str = "xyxy",
      iou_threshold: Optional[float] = None,
      class_metrics: bool = False,
      respect_labels: bool = True,
      **kwargs: Any,
  ) -> None:
      if not _TORCHVISION_GREATER_EQUAL_0_13:
          raise ModuleNotFoundError(
              f"Metric `{self._iou_type.upper()}` requires that `torchvision` version 0.13.0 or newer is installed."
              " Please install with `pip install torchvision>=0.13` or `pip install torchmetrics[detection]`."
          )
      super().__init__(
          box_format,
          iou_threshold,
          class_metrics,
          respect_labels,
          **kwargs,
      )
  
file_path: torchmetrics/src/torchmetrics/detection/diou.py
imports: from typing import Any, Optional, Sequence, Union
  from torch import Tensor
  from torchmetrics.detection.iou import IntersectionOverUnion
  from torchmetrics.functional.detection.diou import _diou_compute, _diou_update
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE, _TORCHVISION_GREATER_EQUAL_0_13
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 1 to create a new DistanceIntersectionOverUnion object from inherited base classes: IntersectionOverUnion with example: obj = DistanceIntersectionOverUnion(box_format, iou_threshold, class_metrics, respect_labels)