docstr: Flush content of the bucket.
docstr_tok: ["Flush","content","of","the","bucket","."]
code: def flush(self) -> None:
      """Flush content of the bucket."""
      if self.offset == 0:
          assert len(self.callbacks) == 0
          return
      # reduce-scatter bucket
      dist.all_reduce(self.buffer[: self.offset], group=self.group)
  
      # execute post-reduction callbacks
      for callback_fn in self.callbacks:
          callback_fn()
      # reuse input bucket but allocate a fresh output shard
      self.offset = 0
      self.callbacks.clear()
      self.buffer = torch.zeros_like(self.buffer)
  
file_path: colossalai/colossalai/legacy/nn/parallel/reducer.py
imports: import functools
  from typing import Callable, Dict, List, Optional, Tuple
  import torch
  import torch.distributed
  from torch import Tensor
  from torch.distributed import ProcessGroup
label_desc: Use image node_id 2 for calling the Bucket obj's underlying member method code with example usage: obj.flush() without return types