code: def random_walk_with_start_prob(graph, nodes, max_depth, proba=0.5):
      """Implement of random walk with the probability of returning the origin node.
  
      This function get random walks path for given nodes and depth.
  
      Args:
          nodes: Walk starting from nodes
          max_depth: Max walking depth
          proba: the proba to return the origin node
  
      Return:
          A list of walks.
      """
      walk = []
      # init
      for node in nodes:
          walk.append([node])
  
      walk_ids = np.arange(0, len(nodes))
      cur_nodes = np.array(nodes)
      nodes = np.array(nodes)
      for l in range(max_depth):
          # select the walks not end
          if l >= 1:
              return_proba = np.random.rand(cur_nodes.shape[0])
              proba_mask = return_proba < proba
              cur_nodes[proba_mask] = nodes[proba_mask]
          outdegree = graph.outdegree(cur_nodes)
          mask = outdegree != 0
          if np.any(mask):
              cur_walk_ids = walk_ids[mask]
              outdegree = outdegree[mask]
          else:
              # stop when all nodes have no successor, wait start next loop to get precesssor
              continue
          succ = graph.successor(cur_nodes[mask])
          sample_index = np.floor(
              np.random.rand(outdegree.shape[0]) * outdegree
          ).astype("int64")
  
          nxt_cur_nodes = cur_nodes
          for s, ind, walk_id in zip(succ, sample_index, cur_walk_ids):
              walk[walk_id].append(s[ind])
              nxt_cur_nodes[walk_id] = s[ind]
          cur_nodes = np.array(nxt_cur_nodes)
      return walk
  
file_path: PGL/legacy/pgl/sample.py
imports: import time
  import copy
  import numpy
  import pgl
  from pgl.utils.logger import log
  from pgl import graph_kernel
label_desc: Use image node_id 10 for calling a global function with example usage: random_walk_with_start_prob(graph, nodes, max_depth, proba) and returns: walk