class_docstr: The :class:`ToDict` class is an :class:`.AdvancedMetric` which will put output from the inner :class:`.Metric` in
  a dict (mapping metric name to value) before returning. When in `eval` mode, 'val_' will be prepended to the metric
  name.
  
  Example: ::
  
      >>> from torchbearer import metrics
  
      >>> @metrics.lambda_metric('my_metric')
      ... def my_metric(y_pred, y_true):
      ...     return y_pred + y_true
      ...
      >>> metric = metrics.ToDict(my_metric().build())
      >>> metric.process({'y_pred': 4, 'y_true': 5})
      {'my_metric': 9}
      >>> metric.eval()
      >>> metric.process({'y_pred': 4, 'y_true': 5})
      {'val_my_metric': 9}
  
  Args:
      metric (Metric): The :class:`.Metric` instance to *wrap*.
class_docstr_tok: ["The",":","class",":","`","ToDict","`","class","is","an",":","class",":","`",".AdvancedMetric","`","which","will","put","output","from","the","inner",":","class",":","`",".Metric","`","in","a","dict","(","mapping","metric","name","to","value",")","before","returning",".","When","in","`","eval","`","mode",",","'val_","'","will","be","prepended","to","the","metric","name",".","Example",":",":",":",">",">",">","from","torchbearer","import","metrics",">",">",">","@","metrics.lambda_metric","(","'my_metric","'",")","...","def","my_metric","(","y_pred",",","y_true",")",":","...","return","y_pred","+","y_true","...",">",">",">","metric","=","metrics.ToDict","(","my_metric","(",")",".build","(",")",")",">",">",">","metric.process","(","{","'y_pred","'",":","4",",","'y_true","'",":","5","}",")","{","'my_metric","'",":","9","}",">",">",">","metric.eval","(",")",">",">",">","metric.process","(","{","'y_pred","'",":","4",",","'y_true","'",":","5","}",")","{","'val_my_metric","'",":","9","}","Args",":","metric","(","Metric",")",":","The",":","class",":","`",".Metric","`","instance","to","*","wrap","*","."]
code: def __init__(self, metric):
      super(ToDict, self).__init__(metric.name)
  
      self.eval_flag = "val"
      self.metric = metric
  
imports: import torchbearer
  from torchbearer.bases import Metric
  from .metrics import AdvancedMetric
  import torch
label_desc: Use image node_id 1 to create a new ToDict object from inherited base classes: AdvancedMetric with example: obj = ToDict(metric)