code: def k_hop_sampler(graph, samples, batch_nodes):
      # for batch_train_samples, batch_train_labels in batch_info:
      start_nodes = copy.deepcopy(batch_nodes)
      nodes = start_nodes
      edges = []
      for max_deg in samples:
          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))
  
          last_nodes = nodes
          nodes = [nodes, pred_nodes]
          nodes = flat_node_and_edge(nodes)
          # Find new nodes
          start_nodes = list(set(nodes) - set(last_nodes))
          if len(start_nodes) == 0:
              break
  
      subgraph = graph.subgraph(
          nodes=nodes,
          edges=edges,
          with_node_feat=True,
          with_edge_feat=True,
      )
      sub_node_index = subgraph.reindex_from_parrent_nodes(batch_nodes)
  
      return subgraph, sub_node_index
  
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 utils.to_undirected import to_undirected
  import ssl
  from pgl.contrib.ogb.nodeproppred.dataset_pgl import PglNodePropPredDataset
  from pgl.sample import graph_saint_random_walk_sample
  from ogb.nodeproppred import Evaluator
  import tqdm
  from collections import namedtuple
  import pgl
  import numpy
  import copy
label_desc: Use image node_id 3 for calling a global function with example usage: k_hop_sampler(graph, samples, batch_nodes) and returns: subgraph,  sub_node_index