code: def test_OnDiskDataset_load_tasks_selectively():
      """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,
          )
          train_path = os.path.join("set", "train.npy")
  
          yaml_content += f"""      - name: node_classification
              num_classes: {num_classes}
              train_set:
                - type: null
                  data:
                    - format: numpy
                      path: {train_path}
          """
          yaml_file = os.path.join(test_dir, "metadata.yaml")
          with open(yaml_file, "w") as f:
              f.write(yaml_content)
  
          # Case1. Test load all tasks.
          dataset = gb.OnDiskDataset(test_dir).load()
          assert len(dataset.tasks) == 2
  
          # Case2. Test load tasks selectively.
          dataset = gb.OnDiskDataset(test_dir).load(
              tasks="link_prediction"
          )
          assert len(dataset.tasks) == 1
          assert dataset.tasks[0].metadata["name"] == "link_prediction"
          dataset = gb.OnDiskDataset(test_dir).load(
              tasks=["link_prediction"]
          )
          assert len(dataset.tasks) == 1
          assert dataset.tasks[0].metadata["name"] == "link_prediction"
  
          # Case3. Test load tasks with non-existent task name.
          with pytest.warns(
              DGLWarning,
              match="Below tasks are not found in YAML: {'fake-name'}. Skipped.",
          ):
              dataset = gb.OnDiskDataset(test_dir).load(
                  tasks=["fake-name"]
              )
              assert len(dataset.tasks) == 0
  
          # Case4. Test load tasks selectively with incorrect task type.
          with pytest.raises(TypeError):
              dataset = gb.OnDiskDataset(test_dir).load(tasks=2)
  
          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 41 for calling a global function with example usage: test_OnDiskDataset_load_tasks_selectively() without return types