code: def preprocess_data(path, name):
      """
      Code adapted from https://github.com/williamleif/GraphSAGE
      """
      print("Processing dataset.")
      prefix = osp.join(path, name)
  
      G_data = json.load(open(prefix + "-G.json"))
      G = json_graph.node_link_graph(G_data)
  
      x = np.load(prefix + "-feats.npy").astype(np.float32)
  
      id_map = json.load(open(prefix + "-id_map.json"))
      if list(id_map.keys())[0].isdigit():
          conversion = int
      else:
          conversion = lambda n: n
      id_map = {conversion(k): int(v) for k, v in id_map.items()}
      n = len(id_map)
  
      class_map = json.load(open(prefix + "-class_map.json"))
      if isinstance(list(class_map.values())[0], list):
          lab_conversion = lambda n: n
      else:
          lab_conversion = int
      class_map = {
          conversion(k): lab_conversion(v) for k, v in class_map.items()
      }
  
      # In Reddit, since edges in G_data are (int, int) and node ids are strings,
      # Networkx weirdly doubles the number of nodes by creating duplicates with integer
      # ids.
      # We create a reverse lookup set to make sure that edges exist when creating the
      # adjacency matrix.
      inverse_ids_lookup = set(id_map.values())
  
      # Adjacency matrix
      edges = [
          edge
          for edge in G.edges()
          if edge[0] in inverse_ids_lookup
          and edge[1] in inverse_ids_lookup
      ]
      edges = np.array(edges, dtype=np.int32)
      adj = sp.csr_matrix(
          (
              np.ones((edges.shape[0]), dtype=np.float32),
              (edges[:, 0], edges[:, 1]),
          ),
          shape=(n, n),
      )
      adj += adj.T
      adj.data = np.clip(adj.data, 0, 1)
  
      # Process labels
      if isinstance(list(class_map.values())[0], list):
          num_classes = len(list(class_map.values())[0])
          y = np.zeros((n, num_classes), dtype=np.float32)
          for k in class_map.keys():
              y[id_map[k], :] = np.array(class_map[k])
      else:
          num_classes = len(set(class_map.values()))
          y = np.zeros((n, num_classes), dtype=np.float32)
          for k in class_map.keys():
              y[id_map[k], class_map[k]] = 1
  
      # Get train/val/test indexes
      idx_va = np.array(
          [
              id_map[k]
              for k in id_map
              if k in G.nodes and G.nodes[k]["val"]
          ],
          dtype=np.int32,
      )
      idx_te = np.array(
          [
              id_map[k]
              for k in id_map
              if k in G.nodes and G.nodes[k]["test"]
          ],
          dtype=np.int32,
      )
      mask_tr = np.ones(n, dtype=bool)
      mask_va = np.zeros(n, dtype=bool)
      mask_te = np.zeros(n, dtype=bool)
      mask_tr[idx_va] = False
      mask_tr[idx_te] = False
      mask_va[idx_va] = True
      mask_te[idx_te] = True
  
      return x, adj, y, mask_tr, mask_va, mask_te
  
imports: import json
  import os
  import os.path
  import shutil
  import numpy
  import scipy.sparse
  from networkx.readwrite import json_graph
  from spektral.data import Dataset, Graph
  from spektral.data.dataset import DATASET_FOLDER
  from spektral.datasets.utils import download_file
label_desc: Use image node_id 1 for calling a global function with example usage: preprocess_data(path, name) and returns: x,  adj,  y,  mask_tr,  mask_va,  mask_te