code: def index2segment_id(num_count):
      """
      num_count: [1, 2, 1]
      return:
          [0, 1, 1, 2]
      """
      index = np.cumsum(num_count, dtype="int64")
      index = np.insert(index, 0, 0)
  
      segments = np.zeros(index[-1] + 1, dtype="int64")
      index = index[:-1]
      segments[index] += 1
      segments = np.cumsum(segments)[:-1] - 1
      return segments
  
imports: import os
  import sys
  import time
  import warnings
  import functools
  import numpy
  from collections import defaultdict, OrderedDict
  import paddle.distributed.fleet
  import pgl
  from pgl.graph_kernel import skip_gram_gen_pair
  from pgl.utils.logger import log
  from pgl.distributed import DistGraphClient, DistGraphServer
  from pgl.utils.data import Dataloader, StreamDataset
  from pgl.distributed import helper
  from pgl.utils.logger import log
  from utils.config import prepare_config
  from datasets.node import NodeGenerator
  from datasets.walk import WalkGenerator
  from datasets.ego_graph import ego_graph_sample, EgoGraphGenerator
  from datasets.pair import PairGenerator
label_desc: Use image node_id 1 for calling a global function with example usage: index2segment_id(num_count) and returns: segments