code: def test_OnDiskDataset_load_graph(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)
  
          # Check the different original_edge_id option to load edge_attributes.
          dataset = gb.OnDiskDataset(
              test_dir, include_original_edge_id=True
          ).load()
          assert (
              dataset.graph.edge_attributes is not None
              and gb.ORIGINAL_EDGE_ID in dataset.graph.edge_attributes
          )
  
          # Case1. Test modify the `type` field.
          dataset = gb.OnDiskDataset(test_dir)
          dataset.yaml_data["graph_topology"]["type"] = "fake_type"
          with pytest.raises(
              pydantic.ValidationError,
              # As error message diffs in pydantic 1.x and 2.x, we just match
              # keyword only.
              match="'FusedCSCSamplingGraph'",
          ):
              dataset.load()
  
          # Case2. Test modify the `path` field.
          dataset = gb.OnDiskDataset(test_dir)
          dataset.yaml_data["graph_topology"]["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_graph = dataset.graph
          dataset.yaml_data["graph_topology"]["path"] = os.path.join(
              test_dir, dataset.yaml_data["graph_topology"]["path"]
          )
          dataset.load()
          modify_graph = dataset.graph
          assert torch.equal(
              original_graph.csc_indptr,
              modify_graph.csc_indptr,
          )
          original_graph = None
          modify_graph = None
          dataset = None
  
      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)
  
          # Test do not generate original_edge_id.
          dataset = gb.OnDiskDataset(
              test_dir, include_original_edge_id=False
          ).load()
          assert (
              dataset.graph.edge_attributes is None
              or gb.ORIGINAL_EDGE_ID
              not in dataset.graph.edge_attributes
          )
          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 28 for calling a global function with example usage: test_OnDiskDataset_load_graph(edge_fmt) without return types