code: def neighbor_sampling(graph, K=2, ratios=(0.1, 0.1, 0.1)):
      # This function takes a DeepSNAP graph, K the number of GNN layers, and neighbor
      # sampling ratios for each layer. This function returns relabeled node feature,
      # edge indices and node_label_index
  
      assert K + 1 == len(ratios)
  
      labeled_nodes = graph.node_label_index.tolist()
      random.shuffle(labeled_nodes)
      num = int(len(labeled_nodes) * ratios[-1])
      if num > 0:
          labeled_nodes = labeled_nodes[:num]
      nodes_list = [set(labeled_nodes)]
      edges_list = []
      all_nodes = labeled_nodes
      for k in range(K):
          # Get nodes and edges from the previous layer
          nodes, all_nodes, edges = sample_neighbors(
              nodes_list[-1],
              graph.G,
              ratios[len(ratios) - k - 2],
              all_nodes,
          )
          nodes_list.append(nodes)
          edges_list.append(edges)
  
      # Reverse the lists
      nodes_list.reverse()
      edges_list.reverse()
  
      (
          relabled_edges_list,
          relabeled_all_nodes,
          relabeled_labeled_nodes,
      ) = relable(all_nodes, labeled_nodes, edges_list)
  
      node_index = nodes_to_tensor(relabeled_all_nodes)
      # All node features that will be used
      node_feature = graph.node_feature[node_index]
      edge_indices = [
          edges_to_tensor(edges) for edges in relabled_edges_list
      ]
      node_label_index = nodes_to_tensor(relabeled_labeled_nodes)
      log = "Sampled {} nodes, {} edges, {} labeled nodes"
      print(
          log.format(
              node_feature.shape[0],
              edge_indices[0].shape[1] // 2,
              node_label_index.shape[0],
          )
      )
      return node_feature, edge_indices, node_label_index
  
imports: import copy
  import torch
  import random
  import argparse
  import numpy
  import networkx
  import torch.nn
  import torch.nn.functional
  from torch_geometric.nn import SAGEConv
  from torch.utils.data import DataLoader
  from torch_geometric.datasets import Planetoid
  from torch.nn import Sequential, Linear, ReLU
  from deepsnap.dataset import GraphDataset
  from deepsnap.graph import Graph
  from model import *
label_desc: Use image node_id 6 for calling a global function with example usage: neighbor_sampling(graph, K, ratios) and returns: node_feature,  edge_indices,  node_label_index