code: def neighbor_sample(graph, nodes, samples):
      assert not graph.is_tensor(), "You must call Graph.numpy() first."
  
      graph_list = []
      for max_deg in samples:
          start_nodes = copy.deepcopy(nodes)
          edges = []
          if max_deg == -1:
              pred_nodes = graph.predecessor(start_nodes)
          else:
              pred_nodes = graph.sample_predecessor(
                  start_nodes, max_degree=max_deg
              )
  
          for dst_node, src_nodes in zip(start_nodes, pred_nodes):
              for src_node in src_nodes:
                  edges.append((src_node, dst_node))
  
          neigh_nodes = [start_nodes, pred_nodes]
          neigh_nodes = flat_node_and_edge(neigh_nodes)
  
          from_reindex = {x: i for i, x in enumerate(neigh_nodes)}
          sub_node_index = graph_kernel.map_nodes(nodes, from_reindex)
  
          sg = subgraph(
              graph,
              nodes=neigh_nodes,
              edges=edges,
              with_node_feat=False,
              with_edge_feat=False,
          )
  
          #         sg = add_self_loop(sg, sub_node_index)
          sg = add_self_loop(sg, sub_node_index)
  
          graph_list.append((sg, neigh_nodes, sub_node_index))
          nodes = neigh_nodes
  
      graph_list = graph_list[::-1]
      return graph_list
  
imports: import os
  import tqdm
  import yaml
  import pgl
  import time
  import copy
  import numpy
  import os.path
  from pgl.utils.logger import log
  from pgl.graph import Graph
  from pgl import graph_kernel
  from pgl.sampling.custom import subgraph
  from ogb.lsc import MAG240MDataset, MAG240MEvaluator
  from dataset.base_dataset import BaseDataGenerator
  import time
label_desc: Use image node_id 4 for calling a global function with example usage: neighbor_sample(graph, nodes, samples) and returns: graph_list