code: def k_hop_sampler(graph, samples, batch_nodes):
      graph_list = []
      for max_deg in samples:
          start_nodes = copy.deepcopy(batch_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))
  
          nodes = [start_nodes, pred_nodes]
          nodes = flat_node_and_edge(nodes)
  
          subgraph = graph.subgraph(
              nodes=nodes,
              edges=edges,
              with_node_feat=False,
              with_edge_feat=False,
          )
          subgraph = add_self_loop_for_subgraph(subgraph)
          sub_node_index = subgraph.reindex_from_parrent_nodes(
              batch_nodes
          )
  
          batch_nodes = nodes
          graph_list.append((subgraph, batch_nodes, sub_node_index))
  
      graph_list = graph_list[::-1]
      #     for k, v in graph._node_feat.items():
      #         graph_list[0][0]._node_feat[k] = v
  
      #     sub_node_index = subgraph.reindex_from_parrent_nodes(batch_nodes)
  
      return graph_list
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from __future__ import absolute_import
  from dataloader.base_dataloader import BaseDataGenerator
  from pgl.contrib.ogb.nodeproppred.dataset_pgl import PglNodePropPredDataset
  import tqdm
  from collections import namedtuple
  import pgl
  import numpy
  import copy
label_desc: Use image node_id 4 for calling a global function with example usage: k_hop_sampler(graph, samples, batch_nodes) and returns: graph_list