code: def process_stats(worker_stats):
      stats = {
          "num_samples": sum(
              stats.pop("num_samples", np.nan) for stats in worker_stats
          )
      }
  
      if "val_num_samples" in worker_stats[0]:
          stats["val_num_samples"] = sum(
              stats.pop("val_num_samples", np.nan)
              for stats in worker_stats
          )
  
      stats = mean_reduce_stats(worker_stats, stats)
  
      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 7 for calling a global function with example usage: process_stats(worker_stats) and returns: stats