code: def get_grad_accumulate_object(tensor):
      """
      Return the AccumulateGrad of the input tensor
      """
  
      # grad_fn reference:
      # https://discuss.pytorch.org/t/in-the-grad-fn-i-find-a-next-functions-but-i-dont-understand-the-meaning-of-the-attribute/24463
      # expand_as reference: https://pytorch.org/docs/stable/generated/torch.Tensor.expand.html#torch.Tensor.expand
      #
      # `next_functions` will return the backward graph where
      # the first element is the AccumulateGrad of the leaf nodes.
      # we want to get the AccumulateGrad of the input tensor instead of the leaf
      # node in the whole computation graph.
      # Therefore, we call expand_as to create a dummy graph
      # where tensor_tmp and tensor indeed point to the same object.
      # You can check this by print(tensor.data_ptr() == tensor_tmp.data_ptr())
      tensor_tmp = tensor.expand_as(tensor)
      grad_acc_obj = tensor_tmp.grad_fn.next_functions[0][0]
      return grad_acc_obj
  
file_path: ColossalAI/colossalai/zero/low_level/_utils.py
imports: import math
  from typing import Optional
  import torch
  import torch.distributed
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
label_desc: Use image node_id 8 for calling a global function with example usage: get_grad_accumulate_object(tensor) and returns: grad_acc_obj