class_docstr: Running wrapper for metrics.
  
  Using this wrapper allows for calculating metrics over a running window of values, instead of the whole history of
  values. This is beneficial when you want to get a better estimate of the metric during training and don't want to
  wait for the whole training to finish to get epoch level estimates.
  
  The running window is defined by the `window` argument. The window is a fixed size and this wrapper will store a
  duplicate of the underlying metric state for each value in the window. Thus memory usage will increase linearly
  with window size. Use accordingly. Also note that the running only works with metrics that have the
  `full_state_update` set to `False`.
  
  Importantly, the wrapper does not alter the value of the `forward` method of the underlying metric. Thus, forward
  will still return the value on the current batch. To get the running value call `compute` instead.
  
  Args:
      base_metric: The metric to wrap.
      window: The size of the running window.
  
  Example (single metric):
      >>> from torch import tensor
      >>> from torchmetrics.wrappers import Running
      >>> from torchmetrics.aggregation import SumMetric
      >>> metric = Running(SumMetric(), window=3)
      >>> for i in range(6):
      ...     current_val = metric(tensor([i]))
      ...     running_val = metric.compute()
      ...     total_val = tensor(sum(list(range(i+1))))  # value we would get from `compute` without running
      ...     print(f"{current_val=}, {running_val=}, {total_val=}")
      current_val=tensor(0.), running_val=tensor(0.), total_val=tensor(0)
      current_val=tensor(1.), running_val=tensor(1.), total_val=tensor(1)
      current_val=tensor(2.), running_val=tensor(3.), total_val=tensor(3)
      current_val=tensor(3.), running_val=tensor(6.), total_val=tensor(6)
      current_val=tensor(4.), running_val=tensor(9.), total_val=tensor(10)
      current_val=tensor(5.), running_val=tensor(12.), total_val=tensor(15)
  
  Example (metric collection):
      >>> from torch import tensor
      >>> from torchmetrics.wrappers import Running
      >>> from torchmetrics import MetricCollection
      >>> from torchmetrics.aggregation import SumMetric, MeanMetric
      >>> # note that running is input to collection, not the other way
      >>> metric = MetricCollection({"sum": Running(SumMetric(), 3), "mean": Running(MeanMetric(), 3)})
      >>> for i in range(6):
      ...     current_val = metric(tensor([i]))
      ...     running_val = metric.compute()
      ...     print(f"{current_val=}, {running_val=}")
      current_val={'mean': tensor(0.), 'sum': tensor(0.)}, running_val={'mean': tensor(0.), 'sum': tensor(0.)}
      current_val={'mean': tensor(1.), 'sum': tensor(1.)}, running_val={'mean': tensor(0.5000), 'sum': tensor(1.)}
      current_val={'mean': tensor(2.), 'sum': tensor(2.)}, running_val={'mean': tensor(1.), 'sum': tensor(3.)}
      current_val={'mean': tensor(3.), 'sum': tensor(3.)}, running_val={'mean': tensor(2.), 'sum': tensor(6.)}
      current_val={'mean': tensor(4.), 'sum': tensor(4.)}, running_val={'mean': tensor(3.), 'sum': tensor(9.)}
      current_val={'mean': tensor(5.), 'sum': tensor(5.)}, running_val={'mean': tensor(4.), 'sum': tensor(12.)}
code: def __init__(self, base_metric: Metric, window: int = 5) -> None:
      super().__init__()
      if not isinstance(base_metric, Metric):
          raise ValueError(
              f"Expected argument `metric` to be an instance of `torchmetrics.Metric` but got {base_metric}"
          )
      if not (isinstance(window, int) and window > 0):
          raise ValueError(
              f"Expected argument `window` to be a positive integer but got {window}"
          )
      self.base_metric = base_metric
      self.window = window
  
      if base_metric.full_state_update is not False:
          raise ValueError(
              f"Expected attribute `full_state_update` set to `False` but got {base_metric.full_state_update}"
          )
      self._num_vals_seen = 0
  
      for key in base_metric._defaults:
          for i in range(window):
              self.add_state(
                  name=key + f"_{i}",
                  default=base_metric._defaults[key],
                  dist_reduce_fx=base_metric._reductions[key],
              )
  
file_path: torchmetrics/src/torchmetrics/wrappers/running.py
imports: from typing import Any, Optional, Sequence, Union
  from torch import Tensor
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
  from torchmetrics.wrappers.abstract import WrapperMetric
label_desc: Use image node_id 1 to create a new Running object from inherited base classes: WrapperMetric with example: obj = Running(base_metric, window)