class_docstr: A utility class to keep track of average values. For example during training/validation loop,
  we need to accumulate the per-batch metrics and calculate the final average value for the whole dataset.
  When training in multi-gpu environment, with DistributedDataParallel, it will average across the processes.
  
  Example:
  
  .. code-block:: python
  
      from monai.metrics import CumulativeAverage
  
      run_avg = CumulativeAverage()
      batch_size = 8
      for i in range(len(train_set)):
          ...
          val = calc_metric(x,y) #some metric value
          run_avg.append(val, count=batch_size)
  
      val_avg = run_avg.aggregate() #average value
docstr: returns the most recent value (averaged across processes)
  
  Args:
      to_numpy: whether to convert to numpy array. Defaults to True
code: def get_current(self, to_numpy: bool = True) -> NdarrayOrTensor:
      """
      returns the most recent value (averaged across processes)
  
      Args:
          to_numpy: whether to convert to numpy array. Defaults to True
      """
      if self.val is None:
          return 0
  
      val = self.val.clone()
      val[~torch.isfinite(val)] = 0
  
      if self.is_distributed:
          val = val / dist.get_world_size()
          dist.all_reduce(val)
  
      if to_numpy:
          val = val.cpu().numpy()
  
      return val
  
file_path: MONAI/monai/metrics/cumulative_average.py
imports: from __future__ import annotations
  import warnings
  from typing import Any
  import torch
  import torch.distributed
  from monai.config import NdarrayOrTensor
label_desc: Use image node_id 3 for calling the CumulativeAverage obj's underlying member method code with example usage: obj.get_current(to_numpy) and returns: val, int