class_docstr: LegacyTUDataset contains lots of graph kernel datasets for graph classification.
  
  Parameters
  ----------
  name : str
      Dataset Name, such as ``ENZYMES``, ``DD``, ``COLLAB``, ``MUTAG``, can be the
      datasets name on `<https://chrsmrrs.github.io/datasets/docs/datasets/>`_.
  use_pandas : bool
      Numpy's file read function has performance issue when file is large,
      using pandas can be faster.
      Default: False
  hidden_size : int
      Some dataset doesn't contain features.
      Use constant node features initialization instead, with hidden size as ``hidden_size``.
      Default : 10
  max_allow_node : int
      Remove graphs that contains more nodes than ``max_allow_node``.
      Default : None
  transform : callable, optional
      A transform that takes in a :class:`~dgl.DGLGraph` object and returns
      a transformed version. The :class:`~dgl.DGLGraph` object will be
      transformed before every access.
  
  Attributes
  ----------
  max_num_node : int
      Maximum number of nodes
  num_classes : int
      Number of classes
  num_labels : numpy.int64
      (DEPRECATED, use num_classes instead) Number of classes
  
  Notes
  -----
  LegacyTUDataset uses provided node feature by default. If no feature provided, it uses one-hot node label instead.
  If neither labels provided, it uses constant for node feature.
  
  The dataset sorts graphs by their labels.
  Shuffle is preferred before manual train/val split.
  
  Examples
  --------
  >>> data = LegacyTUDataset('DD')
  
  The dataset instance is an iterable
  
  >>> len(data)
  1178
  >>> g, label = data[1024]
  >>> g
  Graph(num_nodes=88, num_edges=410,
        ndata_schemes={'feat': Scheme(shape=(89,), dtype=torch.float32), '_ID': Scheme(shape=(), dtype=torch.int64)}
        edata_schemes={'_ID': Scheme(shape=(), dtype=torch.int64)})
  >>> label
  tensor(1)
  
  Batch the graphs and labels for mini-batch training
  
  >>> graphs, labels = zip(*[data[i] for i in range(16)])
  >>> batched_graphs = dgl.batch(graphs)
  >>> batched_labels = torch.tensor(labels)
  >>> batched_graphs
  Graph(num_nodes=9539, num_edges=47382,
        ndata_schemes={'feat': Scheme(shape=(89,), dtype=torch.float32), '_ID': Scheme(shape=(), dtype=torch.int64)}
        edata_schemes={'_ID': Scheme(shape=(), dtype=torch.int64)})
code: def process(self):
      self.data_mode = None
  
      if self.use_pandas:
          import pandas as pd
  
          DS_edge_list = self._idx_from_zero(
              pd.read_csv(
                  self._file_path("A"),
                  delimiter=",",
                  dtype=int,
                  header=None,
              ).values
          )
      else:
          DS_edge_list = self._idx_from_zero(
              np.genfromtxt(
                  self._file_path("A"), delimiter=",", dtype=int
              )
          )
  
      DS_indicator = self._idx_from_zero(
          np.genfromtxt(self._file_path("graph_indicator"), dtype=int)
      )
      if os.path.exists(self._file_path("graph_labels")):
          DS_graph_labels = self._idx_from_zero(
              np.genfromtxt(self._file_path("graph_labels"), dtype=int)
          )
          self.num_labels = max(DS_graph_labels) + 1
          self.graph_labels = DS_graph_labels
      elif os.path.exists(self._file_path("graph_attributes")):
          DS_graph_labels = np.genfromtxt(
              self._file_path("graph_attributes"), dtype=float
          )
          self.num_labels = None
          self.graph_labels = DS_graph_labels
      else:
          raise Exception("Unknown graph label or graph attributes")
  
      g = dgl_graph(([], []))
      g.add_nodes(int(DS_edge_list.max()) + 1)
      g.add_edges(DS_edge_list[:, 0], DS_edge_list[:, 1])
  
      node_idx_list = []
      self.max_num_node = 0
      for idx in range(np.max(DS_indicator) + 1):
          node_idx = np.where(DS_indicator == idx)
          node_idx_list.append(node_idx[0])
          if len(node_idx[0]) > self.max_num_node:
              self.max_num_node = len(node_idx[0])
  
      self.graph_lists = [
          g.subgraph(node_idx) for node_idx in node_idx_list
      ]
  
      try:
          DS_node_labels = self._idx_from_zero(
              np.loadtxt(self._file_path("node_labels"), dtype=int)
          )
          g.ndata["node_label"] = F.tensor(DS_node_labels)
          one_hot_node_labels = self._to_onehot(DS_node_labels)
          for idxs, g in zip(node_idx_list, self.graph_lists):
              g.ndata["feat"] = F.tensor(
                  one_hot_node_labels[idxs, :], F.float32
              )
          self.data_mode = "node_label"
      except IOError:
          print("No Node Label Data")
  
      try:
          DS_node_attr = np.loadtxt(
              self._file_path("node_attributes"), delimiter=","
          )
          if DS_node_attr.ndim == 1:
              DS_node_attr = np.expand_dims(DS_node_attr, -1)
          for idxs, g in zip(node_idx_list, self.graph_lists):
              g.ndata["feat"] = F.tensor(
                  DS_node_attr[idxs, :], F.float32
              )
          self.data_mode = "node_attr"
      except IOError:
          print("No Node Attribute Data")
  
      if "feat" not in g.ndata.keys():
          for idxs, g in zip(node_idx_list, self.graph_lists):
              g.ndata["feat"] = F.ones(
                  (g.num_nodes(), self.hidden_size), F.float32, F.cpu()
              )
          self.data_mode = "constant"
          if self.verbose:
              print(
                  "Use Constant one as Feature with hidden size {}".format(
                      self.hidden_size
                  )
              )
  
      # remove graphs that are too large by user given standard
      # optional pre-processing steop in conformity with Rex Ying's original
      # DiffPool implementation
      if self.max_allow_node:
          preserve_idx = []
          if self.verbose:
              print("original dataset length : ", len(self.graph_lists))
          for i, g in enumerate(self.graph_lists):
              if g.num_nodes() <= self.max_allow_node:
                  preserve_idx.append(i)
          self.graph_lists = [self.graph_lists[i] for i in preserve_idx]
          if self.verbose:
              print(
                  "after pruning graphs that are too big : ",
                  len(self.graph_lists),
              )
          self.graph_labels = [
              self.graph_labels[i] for i in preserve_idx
          ]
          self.max_num_node = self.max_allow_node
      self.graph_labels = F.tensor(self.graph_labels)
  
imports: from __future__ import absolute_import
  import os
  import numpy
  from ..None import backend
  from ..convert import graph
  from .dgl_dataset import DGLBuiltinDataset
  from .utils import load_graphs, load_info, loadtxt, save_graphs, save_info
label_desc: Use image node_id 2 for calling the LegacyTUDataset obj's underlying member method code with example usage: obj.process() without return types