code: def _test_load_yaml_with_sanity_check():
      from dgl.data.csv_dataset_base import load_yaml_with_sanity_check
  
      with tempfile.TemporaryDirectory() as test_dir:
          yaml_path = os.path.join(test_dir, "meta.yaml")
          # workable but meaningless usually
          yaml_data = {
              "dataset_name": "default",
              "node_data": [],
              "edge_data": [],
          }
          with open(yaml_path, "w") as f:
              yaml.dump(yaml_data, f, sort_keys=False)
          meta = load_yaml_with_sanity_check(yaml_path)
          assert meta.version == "1.0.0"
          assert meta.dataset_name == "default"
          assert meta.separator == ","
          assert len(meta.node_data) == 0
          assert len(meta.edge_data) == 0
          assert meta.graph_data is None
          # minimum with required fields only
          yaml_data = {
              "version": "1.0.0",
              "dataset_name": "default",
              "node_data": [{"file_name": "nodes.csv"}],
              "edge_data": [{"file_name": "edges.csv"}],
          }
          with open(yaml_path, "w") as f:
              yaml.dump(yaml_data, f, sort_keys=False)
          meta = load_yaml_with_sanity_check(yaml_path)
          for ndata in meta.node_data:
              assert ndata.file_name == "nodes.csv"
              assert ndata.ntype == "_V"
              assert ndata.graph_id_field == "graph_id"
              assert ndata.node_id_field == "node_id"
          for edata in meta.edge_data:
              assert edata.file_name == "edges.csv"
              assert edata.etype == ["_V", "_E", "_V"]
              assert edata.graph_id_field == "graph_id"
              assert edata.src_id_field == "src_id"
              assert edata.dst_id_field == "dst_id"
          # optional fields are specified
          yaml_data = {
              "version": "1.0.0",
              "dataset_name": "default",
              "separator": "|",
              "node_data": [
                  {
                      "file_name": "nodes.csv",
                      "ntype": "user",
                      "graph_id_field": "xxx",
                      "node_id_field": "xxx",
                  }
              ],
              "edge_data": [
                  {
                      "file_name": "edges.csv",
                      "etype": ["user", "follow", "user"],
                      "graph_id_field": "xxx",
                      "src_id_field": "xxx",
                      "dst_id_field": "xxx",
                  }
              ],
              "graph_data": {
                  "file_name": "graph.csv",
                  "graph_id_field": "xxx",
              },
          }
          with open(yaml_path, "w") as f:
              yaml.dump(yaml_data, f, sort_keys=False)
          meta = load_yaml_with_sanity_check(yaml_path)
          assert len(meta.node_data) == 1
          ndata = meta.node_data[0]
          assert ndata.ntype == "user"
          assert ndata.graph_id_field == "xxx"
          assert ndata.node_id_field == "xxx"
          assert len(meta.edge_data) == 1
          edata = meta.edge_data[0]
          assert edata.etype == ["user", "follow", "user"]
          assert edata.graph_id_field == "xxx"
          assert edata.src_id_field == "xxx"
          assert edata.dst_id_field == "xxx"
          assert meta.graph_data is not None
          assert meta.graph_data.file_name == "graph.csv"
          assert meta.graph_data.graph_id_field == "xxx"
          # some required fields are missing
          yaml_data = {
              "dataset_name": "default",
              "node_data": [],
              "edge_data": [],
          }
          for field in yaml_data.keys():
              ydata = {k: v for k, v in yaml_data.items()}
              ydata.pop(field)
              with open(yaml_path, "w") as f:
                  yaml.dump(ydata, f, sort_keys=False)
              expect_except = False
              try:
                  meta = load_yaml_with_sanity_check(yaml_path)
              except:
                  expect_except = True
              assert expect_except
          # inapplicable version
          yaml_data = {
              "version": "0.0.0",
              "dataset_name": "default",
              "node_data": [{"file_name": "nodes_0.csv"}],
              "edge_data": [{"file_name": "edges_0.csv"}],
          }
          with open(yaml_path, "w") as f:
              yaml.dump(yaml_data, f, sort_keys=False)
          expect_except = False
          try:
              meta = load_yaml_with_sanity_check(yaml_path)
          except DGLError:
              expect_except = True
          assert expect_except
          # duplicate node types
          yaml_data = {
              "version": "1.0.0",
              "dataset_name": "default",
              "node_data": [
                  {"file_name": "nodes.csv"},
                  {"file_name": "nodes.csv"},
              ],
              "edge_data": [{"file_name": "edges.csv"}],
          }
          with open(yaml_path, "w") as f:
              yaml.dump(yaml_data, f, sort_keys=False)
          expect_except = False
          try:
              meta = load_yaml_with_sanity_check(yaml_path)
          except DGLError:
              expect_except = True
          assert expect_except
          # duplicate edge types
          yaml_data = {
              "version": "1.0.0",
              "dataset_name": "default",
              "node_data": [{"file_name": "nodes.csv"}],
              "edge_data": [
                  {"file_name": "edges.csv"},
                  {"file_name": "edges.csv"},
              ],
          }
          with open(yaml_path, "w") as f:
              yaml.dump(yaml_data, f, sort_keys=False)
          expect_except = False
          try:
              meta = load_yaml_with_sanity_check(yaml_path)
          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 22 for calling a global function with example usage: _test_load_yaml_with_sanity_check() without return types