code: def _test_load_graph_data_from_csv():
      from dgl.data.csv_dataset_base import (
          DefaultDataParser,
          GraphData,
          MetaGraph,
      )
  
      with tempfile.TemporaryDirectory() as test_dir:
          num_graphs = 100
          # minimum
          df = pd.DataFrame({"graph_id": np.arange(num_graphs)})
          csv_path = os.path.join(test_dir, "graph.csv")
          df.to_csv(csv_path, index=False)
          meta_graph = MetaGraph(file_name=csv_path)
          graph_data = GraphData.load_from_csv(
              meta_graph, DefaultDataParser()
          )
          assert np.array_equal(df["graph_id"], graph_data.graph_id)
          assert len(graph_data.data) == 0
  
          # common case
          df = pd.DataFrame(
              {
                  "graph_id": np.arange(num_graphs),
                  "label": np.random.randint(3, size=num_graphs),
              }
          )
          csv_path = os.path.join(test_dir, "graph.csv")
          df.to_csv(csv_path, index=False)
          meta_graph = MetaGraph(file_name=csv_path)
          graph_data = GraphData.load_from_csv(
              meta_graph, DefaultDataParser()
          )
          assert np.array_equal(df["graph_id"], graph_data.graph_id)
          assert len(graph_data.data) == 1
          assert np.array_equal(df["label"], graph_data.data["label"])
  
          # add more fields into graph.csv
          df = pd.DataFrame(
              {
                  "graph_id": np.arange(num_graphs),
                  "feat": np.random.randint(3, size=num_graphs),
                  "label": np.random.randint(3, size=num_graphs),
              }
          )
          csv_path = os.path.join(test_dir, "graph.csv")
          df.to_csv(csv_path, index=False)
          meta_graph = MetaGraph(file_name=csv_path)
          graph_data = GraphData.load_from_csv(
              meta_graph, DefaultDataParser()
          )
          assert np.array_equal(df["graph_id"], graph_data.graph_id)
          assert len(graph_data.data) == 2
          assert np.array_equal(df["feat"], graph_data.data["feat"])
          assert np.array_equal(df["label"], graph_data.data["label"])
  
          # required header is missing
          df = pd.DataFrame(
              {"label": np.random.randint(3, size=num_graphs)}
          )
          csv_path = os.path.join(test_dir, "graph.csv")
          df.to_csv(csv_path, index=False)
          meta_graph = MetaGraph(file_name=csv_path)
          expect_except = False
          try:
              GraphData.load_from_csv(meta_graph, DefaultDataParser())
          except DGLError:
              expect_except = True
          assert expect_except
  
imports: import gzip
  import io
  import os
  import tarfile
  import tempfile
  import unittest
  import warnings
  import backend
  import dgl
  import dgl.data
  import numpy
  import pandas
  import pytest
  import yaml
  from dgl import DGLError
label_desc: Use image node_id 25 for calling a global function with example usage: _test_load_graph_data_from_csv() without return types