docstr: Setup the buffers if they are not allocated.
  
  Using ``setup`` and ``teardown``, we can ensure that the bucket
  buffers are only allocated during the backward pass, hence saving more
  memory to other parts of the training process, such as the forward pass
  for activation memory.
docstr_tok: ["Setup","the","buffers","if","they","are","not","allocated",".","Using","``","setup","``","and","``","teardown","``",",","we","can","ensure","that","the","bucket","buffers","are","only","allocated","during","the","backward","pass",",","hence","saving","more","memory","to","other","parts","of","the","training","process",",","such","as","the","forward","pass","for","activation","memory","."]
code: def alloc(self) -> None:
      """Setup the buffers if they are not allocated.
  
      Using ``setup`` and ``teardown``, we can ensure that the bucket
      buffers are only allocated during the backward pass, hence saving more
      memory to other parts of the training process, such as the forward pass
      for activation memory.
      """
      for tensor in [self.buffer, self.output_shard]:
          if tensor.storage().size() == 0:
              tensor.storage().resize_(tensor.size().numel())
  
file_path: ColossalAI/colossalai/legacy/zero/sharded_model/reduce_scatter.py
imports: import functools
  import os
  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 3 for calling the Bucket obj's underlying member method code with example usage: obj.alloc() without return types