class_docstr: Cora dataset implementation.
  
  Args:
  
      symmetry_edges (bool): Whether to create symmetry edges.
  
      self_loop (bool):  Whether to contain self loop edges.
  
  Attributes:
  
      graph (pgl.Graph): The :code:`Graph` data object.
  
      y (numpy.ndarray): Labels for each nodes.
  
      num_classes (int): Number of classes.
  
      train_index (numpy.ndarray): The index for nodes in training set.
  
      val_index (numpy.ndarray): The index for nodes in validation set.
  
      test_index (numpy.ndarray): The index for nodes in test set.
class_docstr_tok: ["Cora","dataset","implementation",".","Args",":","symmetry_edges","(","bool",")",":","Whether","to","create","symmetry","edges",".","self_loop","(","bool",")",":","Whether","to","contain","self","loop","edges",".","Attributes",":","graph","(","pgl.Graph",")",":","The",":","code",":","`","Graph","`","data","object",".","y","(","numpy.ndarray",")",":","Labels","for","each","nodes",".","num_classes","(","int",")",":","Number","of","classes",".","train_index","(","numpy.ndarray",")",":","The","index","for","nodes","in","training","set",".","val_index","(","numpy.ndarray",")",":","The","index","for","nodes","in","validation","set",".","test_index","(","numpy.ndarray",")",":","The","index","for","nodes","in","test","set","."]
docstr: Load data
docstr_tok: ["Load","data"]
code: def _load_data(self):
      """Load data"""
      content = os.path.join(self.path, "cora.content")
      cite = os.path.join(self.path, "cora.cites")
      node_feature = []
      paper_ids = []
      y = []
      y_dict = {}
      with open(content, "r") as f:
          for line in f:
              line = line.strip().split()
              paper_id = int(line[0])
              paper_class = line[-1]
              if paper_class not in y_dict:
                  y_dict[paper_class] = len(y_dict)
              feature = [int(i) for i in line[1:-1]]
              feature_array = np.array(feature, dtype="float32")
              # Normalize
              feature_array = feature_array / (
                  np.sum(feature_array) + 1e-15
              )
              node_feature.append(feature_array)
              y.append(y_dict[paper_class])
              paper_ids.append(paper_id)
      paper2vid = dict([(v, k) for (k, v) in enumerate(paper_ids)])
      num_nodes = len(paper_ids)
      node_feature = np.array(node_feature, dtype="float32")
  
      all_edges = []
      with open(cite, "r") as f:
          for line in f:
              u, v = line.split()
              u = paper2vid[int(u)]
              v = paper2vid[int(v)]
              all_edges.append((u, v))
              if self.symmetry_edges:
                  all_edges.append((v, u))
  
      if self.self_loop:
          for i in range(num_nodes):
              all_edges.append((i, i))
  
      all_edges = list(set(all_edges))
      self.graph = Graph(
          num_nodes=num_nodes,
          edges=all_edges,
          node_feat={"words": node_feature},
      )
      perm = np.arange(0, num_nodes)
      # np.random.shuffle(perm)
      self.train_index = perm[:140]
      self.val_index = perm[200:500]
      self.test_index = perm[500:1500]
      self.y = np.array(y, dtype="int64")
      self.num_classes = len(y_dict)
  
imports: import os
  import io
  import sys
  import numpy
  import pickle
  from pgl.graph import Graph
label_desc: Use image node_id 2 for calling the CoraDataset obj's underlying member method code with example usage: obj._load_data() without return types