class_docstr: Profiler context manager
  
  Usage::
  
      world_size = 4
      inputs = torch.randn(10, 10, dtype=torch.float32, device=get_current_device())
      outputs = torch.empty(world_size, 10, 10, dtype=torch.float32, device=get_current_device())
      outputs_list = list(torch.chunk(outputs, chunks=world_size, dim=0))
  
      cc_prof = CommProfiler()
  
      with ProfilerContext([cc_prof]) as prof:
          op = dist.all_reduce(inputs, async_op=True)
          dist.all_gather(outputs_list, inputs)
          op.wait()
          dist.reduce_scatter(inputs, outputs_list)
          dist.broadcast(inputs, 0)
          dist.reduce(inputs, 0)
  
      prof.show()
code: def to_file(self, log_dir: Union[str, Path]):
      if isinstance(log_dir, str):
          log_dir = Path(log_dir)
  
      if not log_dir.exists():
          log_dir.mkdir(parents=True, exist_ok=True)
      for prof in self.profilers:
          log_file = log_dir.joinpath(
              f"{prof.name}_rank_{gpc.get_global_rank()}.log"
          )
          prof.to_file(log_file)
  
imports: from abc import ABC, abstractmethod
  from pathlib import Path
  from typing import List, Union
  from colossalai.legacy.core import global_context
label_desc: Use image node_id 5 for calling the ProfilerContext obj's underlying member method code with example usage: obj.to_file(log_dir) without return types