class_docstr: Wraps the categorical pairwise metrics of MetricsReloaded.
  
  
  Args:
      metric_name: Name of a categorical metric from the MetricsReloaded package.
      include_background: whether to include computation on the first channel of
          the predicted output. Defaults to ``True``.
      reduction: define mode of reduction to the metrics, will only apply reduction on `not-nan` values,
          available reduction modes: {``"none"``, ``"mean"``, ``"sum"``, ``"mean_batch"``, ``"sum_batch"``,
          ``"mean_channel"``, ``"sum_channel"``}, default to ``"mean"``. if "none", will not do reduction.
      get_not_nans: whether to return the `not_nans` count, if True, aggregate() returns (metric, not_nans).
          Here `not_nans` count the number of not nans for the metric,
          thus its shape equals to the shape of the metric.
      smooth_dr: a small constant added to the denominator to avoid nan. OBS: should be greater than zero.
  
  Example:
  
  .. code-block:: python
  
      import torch
      from monai.metrics import MetricsReloadedCategorical
  
      metric_name = "Weighted Cohens Kappa"
      metric = MetricsReloadedCategorical(metric_name=metric_name)
  
      # first iteration
      # shape [bach=1, channel=3, 2, 2]
      y_pred = torch.tensor([[[[0, 0], [0, 1]], [[0, 0], [0, 0]], [[1, 1], [1, 0]]]])
      y = torch.tensor([[[[1, 0], [0, 1]], [[0, 1], [0, 0]], [[0, 0], [1, 0]]]])
      print(metric(y_pred, y))
  
      # second iteration
      # shape [batch=1, channel=3, 2, 2]
      y_pred = torch.tensor([[[[1, 0], [0, 1]], [[0, 1], [1, 0]], [[0, 0], [0, 0]]]])
      y = torch.tensor([[[[1, 0], [0, 1]], [[0, 1], [0, 0]], [[0, 0], [1, 0]]]])
      print(metric(y_pred, y))
  
      # aggregate
      # shape ([batch=2, channel=1])
      print(metric.aggregate(reduction="none"))  # tensor([[0.2727], [0.6000]])
  
      # reset
      metric.reset()
class_docstr_tok: ["Wraps","the","categorical","pairwise","metrics","of","MetricsReloaded",".","Args",":","metric_name",":","Name","of","a","categorical","metric","from","the","MetricsReloaded","package",".","include_background",":","whether","to","include","computation","on","the","first","channel","of","the","predicted","output",".","Defaults","to","``","True","``",".","reduction",":","define","mode","of","reduction","to","the","metrics",",","will","only","apply","reduction","on","`","not-nan","`","values",",","available","reduction","modes",":","{","``","``","none","''","``",",","``","``","mean","''","``",",","``","``","sum","''","``",",","``","``","mean_batch","''","``",",","``","``","sum_batch","''","``",",","``","``","mean_channel","''","``",",","``","``","sum_channel","''","``","}",",","default","to","``","``","mean","''","``",".","if","``","none","''",",","will","not","do","reduction",".","get_not_nans",":","whether","to","return","the","`","not_nans","`","count",",","if","True",",","aggregate","(",")","returns","(","metric",",","not_nans",")",".","Here","`","not_nans","`","count","the","number","of","not","nans","for","the","metric",",","thus","its","shape","equals","to","the","shape","of","the","metric",".","smooth_dr",":","a","small","constant","added","to","the","denominator","to","avoid","nan",".","OBS",":","should","be","greater","than","zero",".","Example",":","..","code-block",":",":","python","import","torch","from","monai.metrics","import","MetricsReloadedCategorical","metric_name","=","``","Weighted","Cohens","Kappa","''","metric","=","MetricsReloadedCategorical","(","metric_name=metric_name",")","#","first","iteration","#","shape","[","bach=1",",","channel=3",",","2",",","2","]","y_pred","=","torch.tensor","(","[","[","[","[","0",",","0","]",",","[","0",",","1","]","]",",","[","[","0",",","0","]",",","[","0",",","0","]","]",",","[","[","1",",","1","]",",","[","1",",","0","]","]","]","]",")","y","=","torch.tensor","(","[","[","[","[","1",",","0","]",",","[","0",",","1","]","]",",","[","[","0",",","1","]",",","[","0",",","0","]","]",",","[","[","0",",","0","]",",","[","1",",","0","]","]","]","]",")","print","(","metric","(","y_pred",",","y",")",")","#","second","iteration","#","shape","[","batch=1",",","channel=3",",","2",",","2","]","y_pred","=","torch.tensor","(","[","[","[","[","1",",","0","]",",","[","0",",","1","]","]",",","[","[","0",",","1","]",",","[","1",",","0","]","]",",","[","[","0",",","0","]",",","[","0",",","0","]","]","]","]",")","y","=","torch.tensor","(","[","[","[","[","1",",","0","]",",","[","0",",","1","]","]",",","[","[","0",",","1","]",",","[","0",",","0","]","]",",","[","[","0",",","0","]",",","[","1",",","0","]","]","]","]",")","print","(","metric","(","y_pred",",","y",")",")","#","aggregate","#","shape","(","[","batch=2",",","channel=1","]",")","print","(","metric.aggregate","(","reduction=","''","none","''",")",")","#","tensor","(","[","[","0.2727","]",",","[","0.6000","]","]",")","#","reset","metric.reset","(",")"]
code: def __init__(
      self,
      metric_name: str,
      include_background: bool = True,
      reduction: MetricReduction | str = MetricReduction.MEAN,
      get_not_nans: bool = False,
      smooth_dr: float = 1e-5,
  ) -> None:
      super().__init__(
          metric_name=metric_name,
          include_background=include_background,
          reduction=reduction,
          get_not_nans=get_not_nans,
      )
      self.smooth_dr = smooth_dr
  
file_path: MONAI/monai/metrics/wrapper.py
imports: from __future__ import annotations
  from typing import cast
  import torch
  from monai.metrics.utils import do_metric_reduction, ignore_background
  from monai.utils import MetricReduction, convert_to_numpy, convert_to_tensor, optional_import
  from .metric import CumulativeIterationMetric
label_desc: Use image node_id 1 to create a new MetricsReloadedCategorical object from inherited base classes: MetricsReloadedWrapper with example: obj = MetricsReloadedCategorical(metric_name, include_background, reduction, get_not_nans, smooth_dr)