class_docstr: Compute the `Panoptic Quality`_ for panoptic segmentations.
  
  .. math::
      PQ = \frac{IOU}{TP + 0.5 FP + 0.5 FN}
  
  where IOU, TP, FP and FN are respectively the sum of the intersection over union for true positives,
  the number of true positives, false positives and false negatives. This metric is inspired by the PQ
  implementation of panopticapi, a standard implementation for the PQ metric for panoptic segmentation.
  
  .. note:
      Points in the target tensor that do not map to a known category ID are automatically ignored in the metric
      computation.
  
  Args:
      things:
          Set of ``category_id`` for countable things.
      stuffs:
          Set of ``category_id`` for uncountable stuffs.
      allow_unknown_preds_category:
          Boolean flag to specify if unknown categories in the predictions are to be ignored in the metric
          computation or raise an exception when found.
  
  
  Raises:
      ValueError:
          If ``things``, ``stuffs`` have at least one common ``category_id``.
      TypeError:
          If ``things``, ``stuffs`` contain non-integer ``category_id``.
  
  Example:
      >>> from torch import tensor
      >>> from torchmetrics.detection import PanopticQuality
      >>> preds = tensor([[[[6, 0], [0, 0], [6, 0], [6, 0]],
      ...                  [[0, 0], [0, 0], [6, 0], [0, 1]],
      ...                  [[0, 0], [0, 0], [6, 0], [0, 1]],
      ...                  [[0, 0], [7, 0], [6, 0], [1, 0]],
      ...                  [[0, 0], [7, 0], [7, 0], [7, 0]]]])
      >>> target = tensor([[[[6, 0], [0, 1], [6, 0], [0, 1]],
      ...                   [[0, 1], [0, 1], [6, 0], [0, 1]],
      ...                   [[0, 1], [0, 1], [6, 0], [1, 0]],
      ...                   [[0, 1], [7, 0], [1, 0], [1, 0]],
      ...                   [[0, 1], [7, 0], [7, 0], [7, 0]]]])
      >>> panoptic_quality = PanopticQuality(things = {0, 1}, stuffs = {6, 7})
      >>> panoptic_quality(preds, target)
      tensor(0.5463, dtype=torch.float64)
class_docstr_tok: ["Compute","the","`","Panoptic","Quality","`","_","for","panoptic","segmentations",".","..","math",":",":","PQ","=","\\frac","{","IOU","}","{","TP","+","0.5","FP","+","0.5","FN","}","where","IOU",",","TP",",","FP","and","FN","are","respectively","the","sum","of","the","intersection","over","union","for","true","positives",",","the","number","of","true","positives",",","false","positives","and","false","negatives",".","This","metric","is","inspired","by","the","PQ","implementation","of","panopticapi",",","a","standard","implementation","for","the","PQ","metric","for","panoptic","segmentation",".","..","note",":","Points","in","the","target","tensor","that","do","not","map","to","a","known","category","ID","are","automatically","ignored","in","the","metric","computation",".","Args",":","things",":","Set","of","``","category_id","``","for","countable","things",".","stuffs",":","Set","of","``","category_id","``","for","uncountable","stuffs",".","allow_unknown_preds_category",":","Boolean","flag","to","specify","if","unknown","categories","in","the","predictions","are","to","be","ignored","in","the","metric","computation","or","raise","an","exception","when","found",".","Raises",":","ValueError",":","If","``","things","``",",","``","stuffs","``","have","at","least","one","common","``","category_id","``",".","TypeError",":","If","``","things","``",",","``","stuffs","``","contain","non-integer","``","category_id","``",".","Example",":",">",">",">","from","torch","import","tensor",">",">",">","from","torchmetrics.detection","import","PanopticQuality",">",">",">","preds","=","tensor","(","[","[","[","[","6",",","0","]",",","[","0",",","0","]",",","[","6",",","0","]",",","[","6",",","0","]","]",",","...","[","[","0",",","0","]",",","[","0",",","0","]",",","[","6",",","0","]",",","[","0",",","1","]","]",",","...","[","[","0",",","0","]",",","[","0",",","0","]",",","[","6",",","0","]",",","[","0",",","1","]","]",",","...","[","[","0",",","0","]",",","[","7",",","0","]",",","[","6",",","0","]",",","[","1",",","0","]","]",",","...","[","[","0",",","0","]",",","[","7",",","0","]",",","[","7",",","0","]",",","[","7",",","0","]","]","]","]",")",">",">",">","target","=","tensor","(","[","[","[","[","6",",","0","]",",","[","0",",","1","]",",","[","6",",","0","]",",","[","0",",","1","]","]",",","...","[","[","0",",","1","]",",","[","0",",","1","]",",","[","6",",","0","]",",","[","0",",","1","]","]",",","...","[","[","0",",","1","]",",","[","0",",","1","]",",","[","6",",","0","]",",","[","1",",","0","]","]",",","...","[","[","0",",","1","]",",","[","7",",","0","]",",","[","1",",","0","]",",","[","1",",","0","]","]",",","...","[","[","0",",","1","]",",","[","7",",","0","]",",","[","7",",","0","]",",","[","7",",","0","]","]","]","]",")",">",">",">","panoptic_quality","=","PanopticQuality","(","things","=","{","0",",","1","}",",","stuffs","=","{","6",",","7","}",")",">",">",">","panoptic_quality","(","preds",",","target",")","tensor","(","0.5463",",","dtype=torch.float64",")"]
docstr: Update state with predictions and targets.
  
  Args:
      preds: panoptic detection of shape ``[batch, *spatial_dims, 2]`` containing
          the pair ``(category_id, instance_id)`` for each point.
          If the ``category_id`` refer to a stuff, the instance_id is ignored.
  
      target: ground truth of shape ``[batch, *spatial_dims, 2]`` containing
          the pair ``(category_id, instance_id)`` for each pixel of the image.
          If the ``category_id`` refer to a stuff, the instance_id is ignored.
  
  Raises:
      TypeError:
          If ``preds`` or ``target`` is not an ``torch.Tensor``.
      ValueError:
          If ``preds`` and ``target`` have different shape.
      ValueError:
          If ``preds`` has less than 3 dimensions.
      ValueError:
          If the final dimension of ``preds`` has size != 2.
docstr_tok: ["Update","state","with","predictions","and","targets",".","Args",":","preds",":","panoptic","detection","of","shape","``","[","batch",",","*","spatial_dims",",","2","]","``","containing","the","pair","``","(","category_id",",","instance_id",")","``","for","each","point",".","If","the","``","category_id","``","refer","to","a","stuff",",","the","instance_id","is","ignored",".","target",":","ground","truth","of","shape","``","[","batch",",","*","spatial_dims",",","2","]","``","containing","the","pair","``","(","category_id",",","instance_id",")","``","for","each","pixel","of","the","image",".","If","the","``","category_id","``","refer","to","a","stuff",",","the","instance_id","is","ignored",".","Raises",":","TypeError",":","If","``","preds","``","or","``","target","``","is","not","an","``","torch.Tensor","``",".","ValueError",":","If","``","preds","``","and","``","target","``","have","different","shape",".","ValueError",":","If","``","preds","``","has","less","than","3","dimensions",".","ValueError",":","If","the","final","dimension","of","``","preds","``","has","size","!","=","2","."]
code: def update(self, preds: Tensor, target: Tensor) -> None:
      r"""Update state with predictions and targets.
  
      Args:
          preds: panoptic detection of shape ``[batch, *spatial_dims, 2]`` containing
              the pair ``(category_id, instance_id)`` for each point.
              If the ``category_id`` refer to a stuff, the instance_id is ignored.
  
          target: ground truth of shape ``[batch, *spatial_dims, 2]`` containing
              the pair ``(category_id, instance_id)`` for each pixel of the image.
              If the ``category_id`` refer to a stuff, the instance_id is ignored.
  
      Raises:
          TypeError:
              If ``preds`` or ``target`` is not an ``torch.Tensor``.
          ValueError:
              If ``preds`` and ``target`` have different shape.
          ValueError:
              If ``preds`` has less than 3 dimensions.
          ValueError:
              If the final dimension of ``preds`` has size != 2.
  
      """
      _validate_inputs(preds, target)
      flatten_preds = _prepocess_inputs(
          self.things,
          self.stuffs,
          preds,
          self.void_color,
          self.allow_unknown_preds_category,
      )
      flatten_target = _prepocess_inputs(
          self.things, self.stuffs, target, self.void_color, True
      )
      (
          iou_sum,
          true_positives,
          false_positives,
          false_negatives,
      ) = _panoptic_quality_update(
          flatten_preds,
          flatten_target,
          self.cat_id_to_continuous_id,
          self.void_color,
      )
      self.iou_sum += iou_sum
      self.true_positives += true_positives
      self.false_positives += false_positives
      self.false_negatives += false_negatives
  
file_path: torchmetrics/src/torchmetrics/detection/panoptic_qualities.py
imports: from typing import Any, Collection, Optional, Sequence, Union
  import torch
  from torch import Tensor
  from torchmetrics.functional.detection._panoptic_quality_common import _get_category_id_to_continuous_id, _get_void_color, _panoptic_quality_compute, _panoptic_quality_update, _parse_categories, _prepocess_inputs, _validate_inputs
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 2 for calling the PanopticQuality obj's underlying member method code with example usage: obj.update(preds, target) without return types