code: def get_index_from_counts(counts):
      """Return index generated from counts
  
      This function return the index from given counts.
  
      For example, when counts = [ 2, 3, 4], return [0, 2, 5, 9]
  
      Args:
          counts: numpy.ndarray of paddle.Tensor
  
      Return:
          Return idnex of the counts
  
      """
      if check_is_tensor(counts):
          index = paddle.concat(
              [
                  paddle.zeros(
                      shape=[
                          1,
                      ],
                      dtype=counts.dtype,
                  ),
                  paddle.cumsum(counts),
              ],
              axis=-1,
          )
      else:
          index = np.cumsum(counts, dtype="int64")
          index = np.insert(index, 0, 0)
      return index
  
file_path: PGL/pgl/utils/op.py
imports: import paddle
  from paddle import _C_ops, _legacy_C_ops
  import numpy
  from pgl.utils.helper import check_is_tensor
label_desc: Use image node_id 2 for calling a global function with example usage: get_index_from_counts(counts) and returns: index