code: def get_graph_nbrhd_paths_randwalk(
      train_graph,
      ent,
      exclude_tuple,
      max_length=1,
      max_paths=200,
      terminate_prob=0.1,
      pad=(-1, -1),
  ):
      """Helper to get paths through random walk excluding a particular tuple."""
      _, er, et = exclude_tuple
      nsample_per_step = int(
          max_paths ** (1.0 / train_graph.max_path_length)
      )
      neighborhood = []
      # paths of length one
      init_edges = list(train_graph.next_edges[ent] - set((er, et)))
      current_paths = _sample_next_edges(init_edges, nsample_per_step)
      current_paths = map(list, current_paths)
      # import pdb; pdb.set_trace()
      # outlog = ""
      for _ in range(max_length - 1):
          next_paths = []
          # outlog += "current_paths: " + str(current_paths) + "\n"
          while len(current_paths) > 0:
              path = current_paths.pop()
              # outlog += "path:" + str(path) + "\n"
              if np.random.random() <= terminate_prob:
                  # Terminate this path
                  neighborhood.append(
                      path
                      + list(pad) * (max_length - int(0.5 * len(path)))
                  )
                  # outlog += "adding to paths, "
                  # outlog += "nbd:" + str(neighborhood) + "\n"
              else:
                  # Expand the node
                  prev_ents = path[1::2]
                  last_ent = path[-1]
                  next_edges = _sample_next_edges(
                      list(train_graph.next_edges[last_ent]),
                      nsample_per_step,
                  )
                  # outlog += "next_edges:" +  str(next_edges) + "\n"
                  for r, e2 in next_edges:
                      # outlog += "\t edge:" + str(r) + str(e2) + "\n"
                      if e2 in prev_ents:
                          # outlog += "skipped " + str(e2) + "\n"
                          continue
                      next_paths.append(path + [r, e2])
                  # outlog += "next_paths:" +  str(next_paths) + "\n"
          current_paths = next_paths
      if current_paths:
          for path in current_paths:
              neighborhood.append(
                  path + list(pad) * (max_length - int(0.5 * len(path)))
              )
  
      # outlog += "final: " + str(neighborhood) + "\n"
      # print(outlog)
      if not neighborhood:
          neighborhood = [[]]
      # import pdb; pdb.set_trace()
      neighborhood = np.array(neighborhood, dtype=int)
      return neighborhood
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import clueweb_text_graph
  import numpy
  import tensorflow
label_desc: Use image node_id 8 for calling a global function with example usage: get_graph_nbrhd_paths_randwalk(train_graph, ent, exclude_tuple, max_length, max_paths, terminate_prob, pad) and returns: neighborhood