code: def log_all(self, print_log=True, show_straggler=False):
      import torch
      from deepspeed.utils.timer import trim_mean
      import deepspeed.comm as dist
      from deepspeed.comm.reduce_op import ReduceOp
  
      if print_log:
          print(
              f"{'Comm. Op': <20}{'Message Size': <20}{'Count': <20}{'Total Latency(ms)': <20}{'Avg Latency(ms)': <20}{'tput_avg (Gbps)': <20}{'busbw_avg (Gbps)': <20}"
          )
      for record_name in self.comms_dict.keys():
          if print_log:
              print(record_name)
          for msg_size, vals in sorted(
              self.comms_dict[record_name].items()
          ):
              # vals[0] is the count for each msg size
              count = vals[0]
              # vals[1] is a list of latency records for each msg size
              total_lat = sum(vals[1])
              # vals[2] and vals[3] are the lists of algbw and busbw, respectively
              # Get rid of outliers when we print
              avg_lat = trim_mean(vals[1], 0.1)
              avg_algbw = trim_mean(vals[2], 0.1)
              avg_busbw = trim_mean(vals[3], 0.1)
              if print_log:
                  print(
                      f"{' ': <20}{convert_size(msg_size): <20}{count: <20}{total_lat: <20.2f}{avg_lat: <20.2f}{avg_algbw: <20.2f}{avg_busbw: <20.2f}"
                  )
  
      if show_straggler:
          if print_log:
              print("_______________________________")
              print("Breakdown with straggler effect")
              print("-------------------------------")
              print(
                  f"{'Comm. Op': <20}{'Message Size': <20}{'Count': <20}{'Total comm lat(ms)': <20}{'Total straggler(ms)': <20}{'Avg comm lat(ms)': <20}{'Avg straggler(ms)': <20}"
              )
          for record_name in self.comms_dict.keys():
              if print_log:
                  print(record_name)
              for msg_size, vals in sorted(
                  self.comms_dict[record_name].items()
              ):
                  # vals[0] is the count for each msg size
                  count = vals[0]
                  # vals[1] is a list of latency records for each msg size
                  lats = torch.tensor(vals[1])
                  min_lats = torch.tensor(vals[1])
                  dist.all_reduce(min_lats, op=ReduceOp.MIN)
                  total_lat = min_lats.sum().item()
                  total_straggler = (lats - min_lats).sum().item()
                  avg_lat = trim_mean(min_lats.tolist(), 0.1)
                  avg_straggler = trim_mean(
                      (lats - min_lats).tolist(), 0.1
                  )
                  if print_log:
                      print(
                          f"{' ': <20}{convert_size(msg_size): <20}{count: <20}{total_lat: <20.2f}{total_straggler: <20.2f}{avg_lat: <20.2f}{avg_straggler: <20.2f}"
                      )
  
file_path: deepspeed/deepspeed/utils/comms_logging.py
imports: import math
  from deepspeed.utils import log_dist
label_desc: Use image node_id 8 for calling the CommsLogger obj's underlying member method code with example usage: obj.log_all(print_log, show_straggler) without return types