class_docstr: A Graphbolt dataset for legacy DGLDataset.
class_docstr_tok: ["A","Graphbolt","dataset","for","legacy","DGLDataset","."]
code: def _init_as_homogeneous_node_pred(self, legacy: DGLDataset):
      legacy = AsNodePredDataset(legacy)
  
      # Initialize tasks.
      tasks = []
      metadata = {
          "num_classes": legacy.num_classes,
          "name": "node_classification",
      }
      train_labels = legacy[0].ndata["label"][legacy.train_idx]
      validation_labels = legacy[0].ndata["label"][legacy.val_idx]
      test_labels = legacy[0].ndata["label"][legacy.test_idx]
      train_set = ItemSet(
          (legacy.train_idx, train_labels),
          names=("seed_nodes", "labels"),
      )
      validation_set = ItemSet(
          (legacy.val_idx, validation_labels),
          names=("seed_nodes", "labels"),
      )
      test_set = ItemSet(
          (legacy.test_idx, test_labels), names=("seed_nodes", "labels")
      )
      task = OnDiskTask(metadata, train_set, validation_set, test_set)
      tasks.append(task)
      self._tasks = tasks
  
      num_nodes = legacy[0].num_nodes()
      self._all_nodes_set = ItemSet(num_nodes, names="seed_nodes")
      features = {}
      for name in legacy[0].ndata.keys():
          tensor = legacy[0].ndata[name]
          if tensor.dim() == 1:
              tensor = tensor.view(-1, 1)
          features[("node", None, name)] = TorchBasedFeature(tensor)
      for name in legacy[0].edata.keys():
          tensor = legacy[0].edata[name]
          if tensor.dim() == 1:
              tensor = tensor.view(-1, 1)
          features[("edge", None, name)] = TorchBasedFeature(tensor)
      self._feature = BasicFeatureStore(features)
      self._graph = from_dglgraph(legacy[0], is_homogeneous=True)
      self._dataset_name = legacy.name
  
file_path: dgl/python/dgl/graphbolt/impl/legacy_dataset.py
imports: from typing import List, Union
  from dgl.data import AsNodePredDataset, DGLDataset
  from ..base import etype_tuple_to_str
  from ..dataset import Dataset, Task
  from ..itemset import ItemSet, ItemSetDict
  from ..sampling_graph import SamplingGraph
  from .basic_feature_store import BasicFeatureStore
  from .fused_csc_sampling_graph import from_dglgraph
  from .ondisk_dataset import OnDiskTask
  from .torch_based_feature_store import TorchBasedFeature
label_desc: Use image node_id 3 for calling the LegacyDataset obj's underlying member method code with example usage: obj._init_as_homogeneous_node_pred(legacy) without return types