code: def pre_process(self):
      processed_dir = osp.join(self.root, "processed")
      pre_processed_file_path = osp.join(
          processed_dir, "dgl_data_processed"
      )
  
      if osp.exists(pre_processed_file_path):
          self.graph, label_dict = load_graphs(pre_processed_file_path)
          if self.is_hetero:
              self.labels = label_dict
          else:
              self.labels = label_dict["labels"]
  
      else:
          ### check if the downloaded file exists
          if self.binary:
              # npz format
              has_necessary_file_simple = osp.exists(
                  osp.join(self.root, "raw", "data.npz")
              ) and (not self.is_hetero)
              has_necessary_file_hetero = (
                  osp.exists(
                      osp.join(self.root, "raw", "edge_index_dict.npz")
                  )
                  and self.is_hetero
              )
          else:
              # csv file
              has_necessary_file_simple = osp.exists(
                  osp.join(self.root, "raw", "edge.csv.gz")
              ) and (not self.is_hetero)
              has_necessary_file_hetero = (
                  osp.exists(
                      osp.join(
                          self.root, "raw", "triplet-type-list.csv.gz"
                      )
                  )
                  and self.is_hetero
              )
  
          has_necessary_file = (
              has_necessary_file_simple or has_necessary_file_hetero
          )
  
          if not has_necessary_file:
              url = self.meta_info["url"]
              if decide_download(url):
                  path = download_url(url, self.original_root)
                  extract_zip(path, self.original_root)
                  os.unlink(path)
                  # delete folder if there exists
                  try:
                      shutil.rmtree(self.root)
                  except:
                      pass
                  shutil.move(
                      osp.join(self.original_root, self.download_name),
                      self.root,
                  )
              else:
                  print("Stop download.")
                  exit(-1)
  
          raw_dir = osp.join(self.root, "raw")
  
          ### pre-process and save
          add_inverse_edge = (
              self.meta_info["add_inverse_edge"] == "True"
          )
  
          if self.meta_info["additional node files"] == "None":
              additional_node_files = []
          else:
              additional_node_files = self.meta_info[
                  "additional node files"
              ].split(",")
  
          if self.meta_info["additional edge files"] == "None":
              additional_edge_files = []
          else:
              additional_edge_files = self.meta_info[
                  "additional edge files"
              ].split(",")
  
          if self.is_hetero:
              graph = read_heterograph_dgl(
                  raw_dir,
                  add_inverse_edge=add_inverse_edge,
                  additional_node_files=additional_node_files,
                  additional_edge_files=additional_edge_files,
                  binary=self.binary,
              )[0]
  
              if self.binary:
                  tmp = np.load(osp.join(raw_dir, "node-label.npz"))
                  label_dict = {}
                  for key in list(tmp.keys()):
                      label_dict[key] = tmp[key]
                  del tmp
              else:
                  label_dict = read_node_label_hetero(raw_dir)
  
              # convert into torch tensor
              if "classification" in self.task_type:
                  for nodetype in label_dict.keys():
                      # detect if there is any nan
                      node_label = label_dict[nodetype]
                      if np.isnan(node_label).any():
                          label_dict[nodetype] = torch.from_numpy(
                              node_label
                          ).to(torch.float32)
                      else:
                          label_dict[nodetype] = torch.from_numpy(
                              node_label
                          ).to(torch.long)
              else:
                  for nodetype in label_dict.keys():
                      node_label = label_dict[nodetype]
                      label_dict[nodetype] = torch.from_numpy(
                          node_label
                      ).to(torch.float32)
  
          else:
              graph = read_graph_dgl(
                  raw_dir,
                  add_inverse_edge=add_inverse_edge,
                  additional_node_files=additional_node_files,
                  additional_edge_files=additional_edge_files,
                  binary=self.binary,
              )[0]
  
              ### adding prediction target
              if self.binary:
                  node_label = np.load(
                      osp.join(raw_dir, "node-label.npz")
                  )["node_label"]
              else:
                  node_label = pd.read_csv(
                      osp.join(raw_dir, "node-label.csv.gz"),
                      compression="gzip",
                      header=None,
                  ).values
  
              if "classification" in self.task_type:
                  # detect if there is any nan
                  if np.isnan(node_label).any():
                      node_label = torch.from_numpy(node_label).to(
                          torch.float32
                      )
                  else:
                      node_label = torch.from_numpy(node_label).to(
                          torch.long
                      )
              else:
                  node_label = torch.from_numpy(node_label).to(
                      torch.float32
                  )
  
              label_dict = {"labels": node_label}
  
          print("Saving...")
          save_graphs(pre_processed_file_path, graph, label_dict)
  
          self.graph, label_dict = load_graphs(pre_processed_file_path)
  
          if self.is_hetero:
              self.labels = label_dict
          else:
              self.labels = label_dict["labels"]
  
file_path: ogb/ogb/nodeproppred/dataset_dgl.py
imports: import pandas
  import shutil, os
  import os.path
  import torch
  import numpy
  from dgl.data.utils import load_graphs, save_graphs, Subset
  import dgl
  from ogb.utils.url import decide_download, download_url, extract_zip
  from ogb.io.read_graph_dgl import read_graph_dgl, read_heterograph_dgl
  from ogb.io.read_graph_raw import read_node_label_hetero, read_nodesplitidx_split_hetero
label_desc: Use image node_id 2 for calling the DglNodePropPredDataset obj's underlying member method code with example usage: obj.pre_process() without return types