code: def test_OnDiskDataset_load_tasks(edge_fmt):
      """Test preprocess of OnDiskDataset."""
      with tempfile.TemporaryDirectory() as test_dir:
          # All metadata fields are specified.
          dataset_name = "graphbolt_test"
          num_nodes = 4000
          num_edges = 20000
          num_classes = 10
  
          # Generate random graph.
          yaml_content = gbt.random_homo_graphbolt_graph(
              test_dir,
              dataset_name,
              num_nodes,
              num_edges,
              num_classes,
              edge_fmt=edge_fmt,
          )
          yaml_file = os.path.join(test_dir, "metadata.yaml")
          with open(yaml_file, "w") as f:
              f.write(yaml_content)
  
          # Case1. Test modify the `name` field.
          dataset = gb.OnDiskDataset(test_dir)
          dataset.yaml_data["tasks"][0]["name"] = "fake_name"
          dataset.load()
          assert dataset.tasks[0].metadata["name"] == "fake_name"
  
          # Case2. Test modify the `num_classes` field.
          dataset = gb.OnDiskDataset(test_dir)
          dataset.yaml_data["tasks"][0]["num_classes"] = 100
          dataset.load()
          assert dataset.tasks[0].metadata["num_classes"] == 100
  
          # Case3. Test modify the `format` field.
          dataset = gb.OnDiskDataset(test_dir)
          # Change the `format` field to torch.
          dataset.yaml_data["tasks"][0]["train_set"][0]["data"][0][
              "format"
          ] = "torch"
          with pytest.raises(pickle.UnpicklingError):
              dataset.load()
  
          dataset = gb.OnDiskDataset(test_dir)
          dataset.yaml_data["tasks"][0]["train_set"][0]["data"][0][
              "format"
          ] = "torch"
          # Change the `in_memory` field to False will also raise an
          # UnpicklingError. Unlike the case of testing `feature_data`.
          dataset.yaml_data["tasks"][0]["train_set"][0]["data"][0][
              "in_memory"
          ] = False
          with pytest.raises(pickle.UnpicklingError):
              dataset.load()
  
          # Case4. Test modify the `path` field.
          dataset = gb.OnDiskDataset(test_dir)
          # Use invalid path will raise an FileNotFoundError.
          dataset.yaml_data["tasks"][0]["train_set"][0]["data"][0][
              "path"
          ] = "fake_path"
          with pytest.raises(
              FileNotFoundError,
              match=r"\[Errno 2\] No such file or directory:",
          ):
              dataset.load()
  
          # Modifying the `path` field to an absolute path should work.
          # In os.path.join, if a segment is an absolute path (which
          # on Windows requires both a drive and a root), then all
          # previous segments are ignored and joining continues from
          # the absolute path segment.
          dataset = gb.OnDiskDataset(test_dir).load()
          original_train_set = dataset.tasks[0].train_set._items
          dataset.yaml_data["tasks"][0]["train_set"][0]["data"][0][
              "path"
          ] = os.path.join(
              test_dir,
              dataset.yaml_data["tasks"][0]["train_set"][0]["data"][0][
                  "path"
              ],
          )
          dataset.load()
          modify_train_set = dataset.tasks[0].train_set._items
          assert torch.equal(
              original_train_set[0],
              modify_train_set[0],
          )
          original_train_set = None
          modify_train_set = None
          dataset = None
  
imports: import os
  import pickle
  import random
  import re
  import tempfile
  import unittest
  import warnings
  import numpy
  import pandas
  import pydantic
  import pytest
  import torch
  import yaml
  from dgl import graphbolt
  from dgl.base import DGLWarning
  from ..None import gb_test_utils
label_desc: Use image node_id 29 for calling a global function with example usage: test_OnDiskDataset_load_tasks(edge_fmt) without return types