code: def _test_load_edge_data_from_csv():
      from dgl.data.csv_dataset_base import (
          DefaultDataParser,
          EdgeData,
          MetaEdge,
      )
  
      with tempfile.TemporaryDirectory() as test_dir:
          num_nodes = 100
          num_edges = 1000
          # minimum
          df = pd.DataFrame(
              {
                  "src_id": np.random.randint(
                      num_nodes, size=num_edges
                  ),
                  "dst_id": np.random.randint(
                      num_nodes, size=num_edges
                  ),
              }
          )
          csv_path = os.path.join(test_dir, "edges.csv")
          df.to_csv(csv_path, index=False)
          meta_edge = MetaEdge(file_name=csv_path)
          edge_data = EdgeData.load_from_csv(
              meta_edge, DefaultDataParser()
          )
          assert np.array_equal(df["src_id"], edge_data.src)
          assert np.array_equal(df["dst_id"], edge_data.dst)
          assert len(edge_data.data) == 0
  
          # common case
          df = pd.DataFrame(
              {
                  "src_id": np.random.randint(
                      num_nodes, size=num_edges
                  ),
                  "dst_id": np.random.randint(
                      num_nodes, size=num_edges
                  ),
                  "label": np.random.randint(3, size=num_edges),
              }
          )
          csv_path = os.path.join(test_dir, "edges.csv")
          df.to_csv(csv_path, index=False)
          meta_edge = MetaEdge(file_name=csv_path)
          edge_data = EdgeData.load_from_csv(
              meta_edge, DefaultDataParser()
          )
          assert np.array_equal(df["src_id"], edge_data.src)
          assert np.array_equal(df["dst_id"], edge_data.dst)
          assert len(edge_data.data) == 1
          assert np.array_equal(df["label"], edge_data.data["label"])
          assert np.array_equal(
              np.full(num_edges, 0), edge_data.graph_id
          )
          assert edge_data.type == ("_V", "_E", "_V")
  
          # add more fields into edges.csv
          df = pd.DataFrame(
              {
                  "src_id": np.random.randint(
                      num_nodes, size=num_edges
                  ),
                  "dst_id": np.random.randint(
                      num_nodes, size=num_edges
                  ),
                  "graph_id": np.arange(num_edges),
                  "feat": np.random.randint(3, size=num_edges),
                  "label": np.random.randint(3, size=num_edges),
              }
          )
          csv_path = os.path.join(test_dir, "edges.csv")
          df.to_csv(csv_path, index=False)
          meta_edge = MetaEdge(file_name=csv_path)
          edge_data = EdgeData.load_from_csv(
              meta_edge, DefaultDataParser()
          )
          assert np.array_equal(df["src_id"], edge_data.src)
          assert np.array_equal(df["dst_id"], edge_data.dst)
          assert len(edge_data.data) == 2
          assert np.array_equal(df["feat"], edge_data.data["feat"])
          assert np.array_equal(df["label"], edge_data.data["label"])
          assert np.array_equal(df["graph_id"], edge_data.graph_id)
          assert edge_data.type == ("_V", "_E", "_V")
  
          # required headers are missing
          df = pd.DataFrame(
              {"src_id": np.random.randint(num_nodes, size=num_edges)}
          )
          csv_path = os.path.join(test_dir, "edges.csv")
          df.to_csv(csv_path, index=False)
          meta_edge = MetaEdge(file_name=csv_path)
          expect_except = False
          try:
              EdgeData.load_from_csv(meta_edge, DefaultDataParser())
          except DGLError:
              expect_except = True
          assert expect_except
          df = pd.DataFrame(
              {"dst_id": np.random.randint(num_nodes, size=num_edges)}
          )
          csv_path = os.path.join(test_dir, "edges.csv")
          df.to_csv(csv_path, index=False)
          meta_edge = MetaEdge(file_name=csv_path)
          expect_except = False
          try:
              EdgeData.load_from_csv(meta_edge, 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 24 for calling a global function with example usage: _test_load_edge_data_from_csv() without return types