class_docstr: A grouping of AverageMeters.
class_docstr_tok: ["A","grouping","of","AverageMeters","."]
docstr: Returns a dict of average and most recent values for each metric.
docstr_tok: ["Returns","a","dict","of","average","and","most","recent","values","for","each","metric","."]
code: def summary(self, sync_stats=False, dist_backend=None):
      """Returns a dict of average and most recent values for each metric."""
      stats = {BATCH_COUNT: self._batch_count, NUM_SAMPLES: self.n}
      for metric, meter in self._meters.items():
          if sync_stats:
              world_size = dist_backend.get_world_size()
              avg = torch.tensor(meter.avg)
              dist_backend.all_reduce(avg)
              last_val = torch.tensor(meter.val)
              dist_backend.all_reduce(last_val)
              avg = avg.item() / world_size
              last_val = last_val.item() / world_size
          else:
              avg = meter.avg
              last_val = meter.val
          stats[str(metric)] = avg
          stats["last_" + str(metric)] = last_val
      return stats
  
imports: import time
  import numbers
  import socket
  import collections
  import numpy
  from contextlib import closing, contextmanager
  import torch
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 3 for calling the AverageMeterCollection obj's underlying member method code with example usage: obj.summary(sync_stats, dist_backend) and returns: stats