code: def running_mean(clazz=None, batch_size=50, step_size=10, dim=None):
      """The :func:`running_mean` decorator is used to add a :class:`.RunningMean` to the :class:`.MetricTree`. If the
      inner class is not a :class:`.MetricTree` then one will be created. The :class:`.RunningMean` will be wrapped in a
      :class:`.ToDict` (with 'running_' prepended to the name) for simplicity.
  
      .. note::
          The decorator function does not need to be called if not desired, both: `@running_mean` and `@running_mean()`
          are acceptable.
  
      Example: ::
  
          >>> import torch
          >>> from torchbearer import metrics
  
          >>> @metrics.running_mean(step_size=2) # Update every 2 steps
          ... @metrics.lambda_metric('my_metric')
          ... def metric(y_pred, y_true):
          ...     return y_pred + y_true
          ...
          >>> metric.reset({})
          >>> metric.process({'y_pred':torch.Tensor([2]), 'y_true':torch.Tensor([2])}) # 4
          {'running_my_metric': 4.0}
          >>> metric.process({'y_pred':torch.Tensor([3]), 'y_true':torch.Tensor([3])}) # 6
          {'running_my_metric': 4.0}
          >>> metric.process({'y_pred':torch.Tensor([4]), 'y_true':torch.Tensor([4])}) # 8, triggers update
          {'running_my_metric': 6.0}
  
      Args:
          clazz: The class to *decorate*
          batch_size (int): See :class:`.RunningMean`
          step_size (int): See :class:`.RunningMean`
          dim (int, tuple): See :class:`.RunningMean`
  
      Returns:
          decorator or :class:`.MetricTree` instance or wrapper
      """
      if clazz is None:
  
          def decorator(clazz):
              return running_mean(
                  clazz,
                  batch_size=batch_size,
                  step_size=step_size,
                  dim=dim,
              )
  
          return decorator
  
      return _wrap_and_add_to_tree(
          clazz,
          lambda metric: ToDict(
              RunningMean(
                  "running_" + metric.name,
                  batch_size=batch_size,
                  step_size=step_size,
                  dim=dim,
              )
          ),
      )
  
file_path: torchbearer/torchbearer/metrics/decorators.py
imports: import inspect
  from torchbearer.metrics import EpochLambda, BatchLambda, ToDict, Mean, MetricTree, Std, Var, RunningMean
  from .metrics import add_default
label_desc: Use image node_id 8 for calling a global function with example usage: running_mean(clazz, batch_size, step_size, dim) and returns: _wrap_and_add_to_tree, decorator, running_mean