class_docstr: Base Metric class based on ignite event handler mechanism.
  The input `prediction` or `label` data can be a PyTorch Tensor or numpy array with batch dim and channel dim,
  or a list of PyTorch Tensor or numpy array without batch dim.
  
  Args:
      metric_fn: callable function or class to compute raw metric results after every iteration.
          expect to return a Tensor with shape (batch, channel, ...) or tuple (Tensor, not_nans).
      loss_fn: A torch _Loss function which is used to generate the LossMetric
      output_transform: callable to extract `y_pred` and `y` from `ignite.engine.state.output` then
          construct `(y_pred, y)` pair, where `y_pred` and `y` can be `batch-first` Tensors or
          lists of `channel-first` Tensors. the form of `(y_pred, y)` is required by the `update()`.
          `engine.state` and `output_transform` inherit from the ignite concept:
          https://pytorch.org/ignite/concepts.html#state, explanation and usage example are in the tutorial:
          https://github.com/Project-MONAI/tutorials/blob/master/modules/batch_output_transform.ipynb.
      save_details: whether to save metric computation details per image, for example: mean_dice of every image.
          default to True, will save to `engine.state.metric_details` dict with the metric name as key.
      reduction: Argument for the LossMetric, look there for details
      get_not_nans: Argument for the LossMetric, look there for details
class_docstr_tok: ["Base","Metric","class","based","on","ignite","event","handler","mechanism",".","The","input","`","prediction","`","or","`","label","`","data","can","be","a","PyTorch","Tensor","or","numpy","array","with","batch","dim","and","channel","dim",",","or","a","list","of","PyTorch","Tensor","or","numpy","array","without","batch","dim",".","Args",":","metric_fn",":","callable","function","or","class","to","compute","raw","metric","results","after","every","iteration",".","expect","to","return","a","Tensor","with","shape","(","batch",",","channel",",","...",")","or","tuple","(","Tensor",",","not_nans",")",".","loss_fn",":","A","torch","_Loss","function","which","is","used","to","generate","the","LossMetric","output_transform",":","callable","to","extract","`","y_pred","`","and","`","y","`","from","`","ignite.engine.state.output","`","then","construct","`","(","y_pred",",","y",")","`","pair",",","where","`","y_pred","`","and","`","y","`","can","be","`","batch-first","`","Tensors","or","lists","of","`","channel-first","`","Tensors",".","the","form","of","`","(","y_pred",",","y",")","`","is","required","by","the","`","update","(",")","`",".","`","engine.state","`","and","`","output_transform","`","inherit","from","the","ignite","concept",":","https",":","\/\/pytorch.org\/ignite\/concepts.html","#","state",",","explanation","and","usage","example","are","in","the","tutorial",":","https",":","\/\/github.com\/Project-MONAI\/tutorials\/blob\/master\/modules\/batch_output_transform.ipynb",".","save_details",":","whether","to","save","metric","computation","details","per","image",",","for","example",":","mean_dice","of","every","image",".","default","to","True",",","will","save","to","`","engine.state.metric_details","`","dict","with","the","metric","name","as","key",".","reduction",":","Argument","for","the","LossMetric",",","look","there","for","details","get_not_nans",":","Argument","for","the","LossMetric",",","look","there","for","details"]
code: def __init__(
      self,
      metric_fn: CumulativeIterationMetric | None = None,
      loss_fn: _Loss | None = None,
      output_transform: Callable = lambda x: x,
      save_details: bool = True,
      reduction: MetricReduction | str = MetricReduction.MEAN,
      get_not_nans: bool = False,
  ) -> None:
      self._is_reduced: bool = False
      self.metric_fn: CumulativeIterationMetric = cast(
          CumulativeIterationMetric, metric_fn
      )
      self.loss_fn = loss_fn
      self.save_details = save_details
      self._scores: list = []
      self._engine: Engine | None = None
      self._name: str | None = None
  
      if self.metric_fn is None and self.loss_fn is None:
          raise ValueError(
              "Either metric_fn or loss_fn have to be passed."
          )
      if self.metric_fn is not None and self.loss_fn is not None:
          raise ValueError(
              "Either metric_fn or loss_fn have to be passed, but not both."
          )
      if self.loss_fn:
          self.metric_fn = LossMetric(
              loss_fn=self.loss_fn,
              reduction=reduction,
              get_not_nans=get_not_nans,
          )
  
      super().__init__(output_transform)
  
file_path: MONAI/monai/handlers/ignite_metric.py
imports: from __future__ import annotations
  import warnings
  from collections.abc import Callable, Sequence
  from typing import TYPE_CHECKING, Any, cast
  import torch
  from torch.nn.modules.loss import _Loss
  from monai.config import IgniteInfo
  from monai.metrics import CumulativeIterationMetric, LossMetric
  from monai.utils import MetricReduction, deprecated, min_version, optional_import
label_desc: Use image node_id 1 to create a new IgniteMetricHandler object from inherited base classes: Metric with example: obj = IgniteMetricHandler(metric_fn, loss_fn, output_transform, save_details, reduction, get_not_nans)