class_docstr: Collect per-iteration metrics and loss value from the attached trainer. This will also collect metric values from
  a given evaluator object which is expected to perform evaluation at the end of training epochs. This class is
  useful for collecting loss and metric values in one place for storage with checkpoint savers (`state_dict` and
  `load_state_dict` methods provided as expected by Pytorch and Ignite) and for graphing during training.
  
  Example::
      # construct an evaluator saving mean dice metric values in the key "val_mean_dice"
      evaluator = SupervisedEvaluator(..., key_val_metric={"val_mean_dice": MeanDice(...)})
  
      # construct the logger and associate with evaluator to extract metric values from
      logger = MetricLogger(evaluator=evaluator)
  
      # construct the trainer with the logger passed in as a handler so that it logs loss values
      trainer = SupervisedTrainer(..., train_handlers=[logger, ValidationHandler(1, evaluator)])
  
      # run training, logger.loss will be a list of (iteration, loss) values, logger.metrics a dict with key
      # "val_mean_dice" storing a list of (iteration, metric) values
      trainer.run()
  
  Args:
      loss_transform: Converts the `output` value from the trainer's state into a loss value
          `engine.state` and `loss_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.
      metric_transform: Converts the metric value coming from the trainer/evaluator's state into a storable value
      evaluator: Optional evaluator to consume metric results from at the end of its evaluation run
class_docstr_tok: ["Collect","per-iteration","metrics","and","loss","value","from","the","attached","trainer",".","This","will","also","collect","metric","values","from","a","given","evaluator","object","which","is","expected","to","perform","evaluation","at","the","end","of","training","epochs",".","This","class","is","useful","for","collecting","loss","and","metric","values","in","one","place","for","storage","with","checkpoint","savers","(","`","state_dict","`","and","`","load_state_dict","`","methods","provided","as","expected","by","Pytorch","and","Ignite",")","and","for","graphing","during","training",".","Example",":",":","#","construct","an","evaluator","saving","mean","dice","metric","values","in","the","key","``","val_mean_dice","''","evaluator","=","SupervisedEvaluator","(","...",",","key_val_metric=","{","``","val_mean_dice","''",":","MeanDice","(","...",")","}",")","#","construct","the","logger","and","associate","with","evaluator","to","extract","metric","values","from","logger","=","MetricLogger","(","evaluator=evaluator",")","#","construct","the","trainer","with","the","logger","passed","in","as","a","handler","so","that","it","logs","loss","values","trainer","=","SupervisedTrainer","(","...",",","train_handlers=","[","logger",",","ValidationHandler","(","1",",","evaluator",")","]",")","#","run","training",",","logger.loss","will","be","a","list","of","(","iteration",",","loss",")","values",",","logger.metrics","a","dict","with","key","#","``","val_mean_dice","''","storing","a","list","of","(","iteration",",","metric",")","values","trainer.run","(",")","Args",":","loss_transform",":","Converts","the","`","output","`","value","from","the","trainer","'s","state","into","a","loss","value","`","engine.state","`","and","`","loss_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",".","metric_transform",":","Converts","the","metric","value","coming","from","the","trainer\/evaluator","'s","state","into","a","storable","value","evaluator",":","Optional","evaluator","to","consume","metric","results","from","at","the","end","of","its","evaluation","run"]
docstr: Log metrics from the given Engine's state member.
  
  Args:
      engine: Ignite Engine to log from
docstr_tok: ["Log","metrics","from","the","given","Engine","'s","state","member",".","Args",":","engine",":","Ignite","Engine","to","log","from"]
code: def log_metrics(self, engine: Engine) -> None:
      """
      Log metrics from the given Engine's state member.
  
      Args:
          engine: Ignite Engine to log from
      """
      with self.lock:
          for m, v in engine.state.metrics.items():
              v = self.metric_transform(v)
              self.metrics[m].append((self.iteration, v))
  
imports: from __future__ import annotations
  from collections import defaultdict
  from collections.abc import Callable, Mapping, Sequence
  from enum import Enum
  from threading import RLock
  from typing import TYPE_CHECKING, Any
  from monai.config import IgniteInfo
  from monai.utils import min_version, optional_import
  from monai.utils.enums import CommonKeys
label_desc: Use image node_id 5 for calling the MetricLogger obj's underlying member method code with example usage: obj.log_metrics(engine) without return types