class_docstr: Communication profiler. Records all communication events.
code: def close_profiler(self, group=None):
      assert self.profiler is not None, "There is no running dist op"
      kernel_name, code_location, vol = self.pending_metadata
      self.profiler.__exit__(None, None, None)
  
      if self.profiler.enabled and dist.get_world_size(group) > 1:
          assert_flag = 0
          current_comm_event = None
          events = self.profiler.function_events
          for event in events:
              if kernel_name in event.name:
                  assert (
                      assert_flag == 0
                  ), "Multiple dist ops has been called "
                  current_comm_event = CommEvent(
                      1, vol, event.self_cuda_time_total
                  )
                  assert_flag += 1
  
          assert (
              current_comm_event is not None
          ), "dist op has not been found"
  
          buffer = torch.tensor(
              [current_comm_event.self_cuda_time],
              device=get_current_device(),
          )
          torch_all_reduce(buffer, op=ReduceOp.MIN, group=group)
          current_comm_event.self_cuda_time = buffer.item()
  
          self.total_count += current_comm_event.self_count
          self.total_comm_vol += current_comm_event.self_comm_vol
          self.total_cuda_time += current_comm_event.self_cuda_time
          if code_location in self.ops_record:
              self.ops_record[code_location].add(current_comm_event)
          else:
              self.ops_record[code_location] = current_comm_event
  
      self.profiler = None
      self.pending_op = None
      self.pending_metadata = None
  
imports: import inspect
  from functools import partial
  from pathlib import Path
  from typing import List, Optional
  import torch
  import torch.distributed
  from torch.autograd.profiler import profile
  from torch.distributed import ReduceOp
  from colossalai.utils import get_current_device
  from .prof_utils import BaseProfiler, _format_bandwidth, _format_memory, _format_time
label_desc: Use image node_id 11 for calling the CommProfiler obj's underlying member method code with example usage: obj.close_profiler(group) without return types