class_docstr: Computes Intersection Over Union (IoU).
  
  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: ``IntTensor`` 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:
  
  - ``iou_dict``: A dictionary containing the following key-values:
  
      - iou: (:class:`~torch.Tensor`)
      - iou/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 IntersectionOverUnion
      >>> preds = [
      ...    {
      ...        "boxes": torch.tensor([
      ...             [296.55, 93.96, 314.97, 152.79],
      ...             [298.55, 98.96, 314.97, 151.79]]),
      ...        "labels": torch.tensor([4, 5]),
      ...    }
      ... ]
      >>> target = [
      ...    {
      ...        "boxes": torch.tensor([[300.00, 100.00, 315.00, 150.00]]),
      ...        "labels": torch.tensor([5]),
      ...    }
      ... ]
      >>> metric = IntersectionOverUnion()
      >>> metric(preds, target)
      {'iou': tensor(0.8614)}
  
  Example::
  
      The metric can also return the score per class:
  
      >>> import torch
      >>> from torchmetrics.detection import IntersectionOverUnion
      >>> preds = [
      ...    {
      ...        "boxes": torch.tensor([
      ...             [296.55, 93.96, 314.97, 152.79],
      ...             [298.55, 98.96, 314.97, 151.79]]),
      ...        "labels": torch.tensor([4, 5]),
      ...    }
      ... ]
      >>> target = [
      ...    {
      ...        "boxes": torch.tensor([
      ...               [300.00, 100.00, 315.00, 150.00],
      ...               [300.00, 100.00, 315.00, 150.00]
      ...        ]),
      ...        "labels": torch.tensor([4, 5]),
      ...    }
      ... ]
      >>> metric = IntersectionOverUnion(class_metrics=True)
      >>> metric(preds, target)
      {'iou': tensor(0.7756), 'iou/cl_4': tensor(0.6898), 'iou/cl_5': tensor(0.8614)}
  
  Raises:
      ModuleNotFoundError:
          If torchvision is not installed with version 0.8.0 or newer.
class_docstr_tok: ["Computes","Intersection","Over","Union","(","IoU",")",".","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",":","``","IntTensor","``","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",":","-","``","iou_dict","``",":","A","dictionary","containing","the","following","key-values",":","-","iou",":","(",":","class",":","`","~torch.Tensor","`",")","-","iou\/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","IntersectionOverUnion",">",">",">","preds","=","[","...","{","...","``","boxes","''",":","torch.tensor","(","[","...","[","296.55",",","93.96",",","314.97",",","152.79","]",",","...","[","298.55",",","98.96",",","314.97",",","151.79","]","]",")",",","...","``","labels","''",":","torch.tensor","(","[","4",",","5","]",")",",","...","}","...","]",">",">",">","target","=","[","...","{","...","``","boxes","''",":","torch.tensor","(","[","[","300.00",",","100.00",",","315.00",",","150.00","]","]",")",",","...","``","labels","''",":","torch.tensor","(","[","5","]",")",",","...","}","...","]",">",">",">","metric","=","IntersectionOverUnion","(",")",">",">",">","metric","(","preds",",","target",")","{","'iou","'",":","tensor","(","0.8614",")","}","Example",":",":","The","metric","can","also","return","the","score","per","class",":",">",">",">","import","torch",">",">",">","from","torchmetrics.detection","import","IntersectionOverUnion",">",">",">","preds","=","[","...","{","...","``","boxes","''",":","torch.tensor","(","[","...","[","296.55",",","93.96",",","314.97",",","152.79","]",",","...","[","298.55",",","98.96",",","314.97",",","151.79","]","]",")",",","...","``","labels","''",":","torch.tensor","(","[","4",",","5","]",")",",","...","}","...","]",">",">",">","target","=","[","...","{","...","``","boxes","''",":","torch.tensor","(","[","...","[","300.00",",","100.00",",","315.00",",","150.00","]",",","...","[","300.00",",","100.00",",","315.00",",","150.00","]","...","]",")",",","...","``","labels","''",":","torch.tensor","(","[","4",",","5","]",")",",","...","}","...","]",">",">",">","metric","=","IntersectionOverUnion","(","class_metrics=True",")",">",">",">","metric","(","preds",",","target",")","{","'iou","'",":","tensor","(","0.7756",")",",","'iou\/cl_4","'",":","tensor","(","0.6898",")",",","'iou\/cl_5","'",":","tensor","(","0.8614",")","}","Raises",":","ModuleNotFoundError",":","If","torchvision","is","not","installed","with","version","0.8.0","or","newer","."]
code: def _get_safe_item_values(self, boxes: Tensor) -> Tensor:
      from torchvision.ops import box_convert
  
      boxes = _fix_empty_tensors(boxes)
      if boxes.numel() > 0:
          boxes = box_convert(
              boxes, in_fmt=self.box_format, out_fmt="xyxy"
          )
      return boxes
  
file_path: torchmetrics/src/torchmetrics/detection/iou.py
imports: from typing import Any, Dict, List, Optional, Sequence, Union
  import torch
  from torch import Tensor
  from torchmetrics.detection.helpers import _fix_empty_tensors, _input_validator
  from torchmetrics.functional.detection.iou import _iou_compute, _iou_update
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.data import dim_zero_cat
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE, _TORCHVISION_GREATER_EQUAL_0_8
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 5 for calling the IntersectionOverUnion obj's underlying member method code with example usage: obj._get_safe_item_values(boxes) and returns: boxes