class_docstr: A wrapper for the optimizer to enable gradient accumulation by skipping the steps
  before accumulation size is reached.
  
  Args:
      optim (:class:`torch.optim.Optimizer`): Your optimizer object for gradient accumulation.
      accumulate_size (int): The number of steps to accumulate gradients.
      model (:class:`torch.nn.Module`):
          Your model object to check if it is DistributedDataParallel for special handling of no_sync() context.
docstr: Execute backward pass given the gradients of the output.
  
  Args:
      loss (:class:`torch.Tensor`): the loss value.
      grad (:class:`torch.Tensor`): the output gradient.
code: def backward_by_grad(self, tensor: Tensor, grad: Tensor) -> None:
      """Execute backward pass given the gradients of the output.
  
      Args:
          loss (:class:`torch.Tensor`): the loss value.
          grad (:class:`torch.Tensor`): the output gradient.
      """
  
      self.accumulate_step += 1
      no_sync = (
          self.is_torch_ddp
          and self.accumulate_step < self.accumulate_size
      )
  
      if no_sync:
          with self.model.no_sync():
              self.optim.backward_by_grad(tensor, grad)
      else:
          self.optim.backward_by_grad(tensor, grad)
  
imports: from typing import Any, Iterable, Tuple, Union
  import torch.nn
  from torch import Tensor
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.optim import Optimizer
  from torch.optim.lr_scheduler import _LRScheduler
  from torch.utils.data import DataLoader
  from colossalai.interface import OptimizerWrapper
  from colossalai.legacy.engine import BaseGradientHandler
  from colossalai.utils import conditional_context
label_desc: Use image node_id 6 for calling the GradAccumOptimizer obj's underlying member method code with example usage: obj.backward_by_grad(tensor, grad) without return types