code: def test_OnDiskDataset_load_feature(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 `in_memory` field.
          dataset = gb.OnDiskDataset(test_dir).load()
          original_feature_data = dataset.feature
          dataset.yaml_data["feature_data"][0]["in_memory"] = True
          load_dataset(dataset)
          modify_feature_data = dataset.feature
          # After modify the `in_memory` field, the feature data should be
          # equal.
          assert torch.equal(
              original_feature_data.read("node", None, "feat"),
              modify_feature_data.read("node", None, "feat"),
          )
  
          # Case2. Test modify the `format` field.
          dataset = gb.OnDiskDataset(test_dir)
          # If `format` is torch and `in_memory` is False, it will
          # raise an AssertionError.
          dataset.yaml_data["feature_data"][0]["in_memory"] = False
          dataset.yaml_data["feature_data"][0]["format"] = "torch"
          with pytest.raises(
              AssertionError,
              match="^Pytorch tensor can only be loaded in memory,",
          ):
              load_dataset(dataset)
  
          dataset = gb.OnDiskDataset(test_dir)
          dataset.yaml_data["feature_data"][0]["in_memory"] = True
          dataset.yaml_data["feature_data"][0]["format"] = "torch"
          # If `format` is torch and `in_memory` is True, it will
          # raise an UnpicklingError.
          with pytest.raises(pickle.UnpicklingError):
              load_dataset(dataset)
  
          # Case3. Test modify the `path` field.
          dataset = gb.OnDiskDataset(test_dir)
          # Use invalid path will raise an FileNotFoundError.
          dataset.yaml_data["feature_data"][0]["path"] = "fake_path"
          with pytest.raises(
              FileNotFoundError,
              match=r"\[Errno 2\] No such file or directory:",
          ):
              load_dataset(dataset)
          # 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 = load_dataset(gb.OnDiskDataset(test_dir))
          original_feature_data = dataset.feature
          dataset.yaml_data["feature_data"][0]["path"] = os.path.join(
              test_dir, dataset.yaml_data["feature_data"][0]["path"]
          )
          load_dataset(dataset)
          modify_feature_data = dataset.feature
          assert torch.equal(
              original_feature_data.read("node", None, "feat"),
              modify_feature_data.read("node", None, "feat"),
          )
          original_feature_data = None
          modify_feature_data = 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 27 for calling a global function with example usage: test_OnDiskDataset_load_feature(edge_fmt) without return types