code: def load_from_planetoid_files(dataset_name, path):
      """Loads Planetoid data in GCN format, as released with the GCN code.
  
      This function is adapted from https://github.com/tkipf/gcn.
  
      This function assumes that the following files can be found at the location
      specified by `path`:
  
      ind.dataset_str.x          => the feature vectors of the training instances
                                    as scipy.sparse.csr.csr_matrix object.
      ind.dataset_str.tx         => the feature vectors of the test instances as
                                    scipy.sparse.csr.csr_matrix object.
      ind.dataset_str.allx       => the feature vectors of both labeled and
                                    unlabeled training instances (a superset of
                                    ind.dataset_str.x) as
                                    scipy.sparse.csr.csr_matrix object.
      ind.dataset_str.y          => the one-hot labels of the labeled training
                                    instances as numpy.ndarray object.
      ind.dataset_str.ty         => the one-hot labels of the test instances as
                                    numpy.ndarray object.
      ind.dataset_str.ally       => the labels for instances in
                                    ind.dataset_str.allx as numpy.ndarray object.
      ind.dataset_str.graph      => a dict in the format
                                    {index: [index_of_neighbor_nodes]} as
                                    collections.defaultdict object.
      ind.dataset_str.test.index => the indices of test instances in graph, for
                                    the inductive setting as list object.
  
      Args:
        dataset_name: A string representing the dataset name (e.g., `cora`).
        path: Path to the directory containing the files.
  
      Returns:
        All data input files loaded (as well the training/test data).
      """
  
      def _sample_mask(idx, l):
          """Create mask."""
          mask = np.zeros(l)
          mask[idx] = 1
          return np.array(mask, dtype=bool)
  
      def _parse_index_file(filename):
          """Parse index file."""
          index = []
          for line in open(filename):
              index.append(int(line.strip()))
          return index
  
      def _load_file(name):
          """Load from data file."""
          filename = "ind.{}.{}".format(dataset_name, name)
          filename = os.path.join(path, filename)
          with open(filename, "rb") as f:
              if sys.version_info > (3, 0):
                  return pickle.load(
                      f, encoding="latin1"
                  )  # pylint: disable=unexpected-keyword-arg
              else:
                  return pickle.load(f)
  
      x = _load_file("x")
      y = _load_file("y")
      tx = _load_file("tx")
      ty = _load_file("ty")
      allx = _load_file("allx")
      ally = _load_file("ally")
      graph = _load_file("graph")
  
      filename = "ind.{}.test.index".format(dataset_name)
      filename = os.path.join(path, filename)
      test_idx_reorder = _parse_index_file(filename)
      test_idx_range = np.sort(test_idx_reorder)
  
      if dataset_name == "citeseer":
          # Fix citeseer dataset (there are some isolated nodes in the graph).
          # Find isolated nodes, add them as zero-vecs into the right position.
          test_idx_range_full = range(
              min(test_idx_reorder), max(test_idx_reorder) + 1
          )
          tx_extended = sp.lil_matrix(
              (len(test_idx_range_full), x.shape[1])
          )
          tx_extended[test_idx_range - min(test_idx_range), :] = tx
          tx = tx_extended
          ty_extended = np.zeros((len(test_idx_range_full), y.shape[1]))
          ty_extended[test_idx_range - min(test_idx_range), :] = ty
          ty = ty_extended
  
      features = sp.vstack((allx, tx)).tolil()
      features[test_idx_reorder, :] = features[test_idx_range, :]
      adj = nx.adjacency_matrix(nx.from_dict_of_lists(graph))
  
      labels = np.vstack((ally, ty))
      labels[test_idx_reorder, :] = labels[test_idx_range, :]
  
      idx_test = test_idx_range.tolist()
      idx_train = range(len(y))
      idx_val = range(len(y), len(y) + 500)
  
      train_mask = _sample_mask(idx_train, labels.shape[0])
      val_mask = _sample_mask(idx_val, labels.shape[0])
      test_mask = _sample_mask(idx_test, labels.shape[0])
  
      y_train = np.zeros(labels.shape)
      y_val = np.zeros(labels.shape)
      y_test = np.zeros(labels.shape)
      y_train[train_mask, :] = labels[train_mask, :]
      y_val[val_mask, :] = labels[val_mask, :]
      y_test[test_mask, :] = labels[test_mask, :]
  
      return (
          adj,
          features,
          y_train,
          y_val,
          y_test,
          train_mask,
          val_mask,
          test_mask,
          labels,
      )
  
file_path: neural-structured-learning/research/gam/gam/data/loaders.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import json
  import logging
  import os
  import pickle
  import sys
  from .dataset import Dataset
  from .dataset import PlanetoidDataset
  import networkx
  import numpy
  from .preprocessing import convert_image
  from .preprocessing import split_train_val_unlabeled
  from scipy import sparse
  import tensorflow_datasets
label_desc: Use image node_id 3 for calling a global function with example usage: load_from_planetoid_files(dataset_name, path) and returns: adj,  features,  y_train,  y_val,  y_test,  train_mask,  val_mask,  test_mask,  labels, np, index, pickle, pickle