class_docstr: Flickr dataset implementation
  
  Args:
      name: The name of the dataset.
  
      symmetry_edges: Whether to create symmetry edges.
  
      self_loop:  Whether to contain self loop edges.
  
      train_percentage: The percentage of nodes to be trained in multi class task.
  
  Attributes:
      graph: The :code:`Graph` data object.
  
      num_groups: Number of classes.
  
      train_index: The index for nodes in training set.
  
      test_index: The index for nodes in validation set.
code: def _load_data(self):
      edge_path = os.path.join(self.path, "edges.txt")
      node_path = os.path.join(self.path, "nodes.txt")
      nodes_label_path = os.path.join(self.path, "nodes_label.txt")
  
      all_edges = []
      edges_weight = []
  
      with io.open(node_path) as inf:
          num_nodes = len(inf.readlines())
  
      node_feature = np.zeros((num_nodes, self.num_groups))
  
      with io.open(nodes_label_path) as inf:
          for line in inf:
              # group_id means the label of the node
              node_id, group_id = line.strip("\n").split(",")
              node_id = int(node_id) - 1
              labels = group_id.split(" ")
              for i in labels:
                  node_feature[node_id][int(i) - 1] = 1
  
      node_degree_list = [1 for _ in range(num_nodes)]
  
      with io.open(edge_path) as inf:
          for line in inf:
              items = line.strip().split("\t")
              if len(items) == 2:
                  u, v = int(items[0]), int(items[1])
                  weight = 1  # binary weight, default set to 1
              else:
                  u, v, weight = (
                      int(items[0]),
                      int(items[1]),
                      float(items[2]),
                  )
              u, v = u - 1, v - 1
              all_edges.append((u, v))
              edges_weight.append(weight)
  
              if self.symmetry_edges:
                  all_edges.append((v, u))
                  edges_weight.append(weight)
  
              # sum the weights of the same node as the outdegree
              node_degree_list[u] += weight
  
      if self.self_loop:
          for i in range(num_nodes):
              all_edges.append((i, i))
              edges_weight.append(1.0)
  
      all_edges = list(set(all_edges))
      self.graph = graph.Graph(
          num_nodes=num_nodes,
          edges=all_edges,
          node_feat={"group_id": node_feature},
      )
  
      perm = np.arange(0, num_nodes)
      np.random.shuffle(perm)
      train_num = int(num_nodes * self.train_percentage)
      self.train_index = perm[:train_num]
      self.test_index = perm[train_num:]
  
      edge_distribution = np.array(edges_weight, dtype=np.float32)
      self.edge_distribution = edge_distribution / np.sum(
          edge_distribution
      )
      self.edge_sampling = AliasSampling(prob=edge_distribution)
  
      node_dist = np.array(node_degree_list, dtype=np.float32)
      node_negative_distribution = np.power(node_dist, 0.75)
      self.node_negative_distribution = (
          node_negative_distribution
          / np.sum(node_negative_distribution)
      )
      self.node_sampling = AliasSampling(
          prob=node_negative_distribution
      )
  
      self.node_index = {}
      self.node_index_reversed = {}
      for index, e in enumerate(self.graph.edges):
          self.node_index[e[0]] = index
          self.node_index_reversed[index] = e[0]
  
file_path: PGL/legacy/examples/line/data_loader.py
imports: import os
  import io
  import sys
  import numpy
  from pgl import graph
  from pgl.utils.logger import log
label_desc: Use image node_id 2 for calling the FlickrDataset obj's underlying member method code with example usage: obj._load_data() without return types