code: def lambda_metric(name, on_epoch=False):
      """The :func:`lambda_metric` decorator is used to convert a lambda function `y_pred, y_true` into a :class:`.Metric`
      instance. This can be used as in the following example: ::
  
          @metrics.lambda_metric('my_metric')
          def my_metric(y_pred, y_true):
              ... # Calculate some metric
  
          model = Model(metrics=[my_metric])
  
      Args:
          name (str): The name of the metric (e.g. 'loss')
          on_epoch (bool): If True the metric will be an instance of :class:`.EpochLambda` instead of :class:`.BatchLambda`
  
      Returns:
          A decorator which replaces a function with a :class:`.Metric`
      """
  
      def decorator(metric_function):
          if on_epoch:
              return EpochLambda(name, metric_function)
          else:
              return BatchLambda(name, metric_function)
  
      return decorator
  
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 2 for calling a global function with example usage: lambda_metric(name, on_epoch) and returns: decorator, EpochLambda, BatchLambda