class_docstr: Class of node data which is used for DGLGraph construction. Internal use only.
class_docstr_tok: ["Class","of","node","data","which","is","used","for","DGLGraph","construction",".","Internal","use","only","."]
code: def to_dict(node_data: List["NodeData"]) -> dict:
      # node_ids could be numeric or non-numeric values, but duplication is not allowed.
      node_dict = {}
      for n_data in node_data:
          graph_ids = np.unique(n_data.graph_id)
          for graph_id in graph_ids:
              idx = n_data.graph_id == graph_id
              ids = n_data.id[idx]
              u_ids, u_indices, u_counts = np.unique(
                  ids, return_index=True, return_counts=True
              )
              if len(ids) > len(u_ids):
                  raise DGLError(
                      "Node IDs are required to be unique but the following ids are duplicate: {}".format(
                          u_ids[u_counts > 1]
                      )
                  )
              if graph_id not in node_dict:
                  node_dict[graph_id] = {}
              node_dict[graph_id][n_data.type] = {
                  "mapping": {
                      index: i for i, index in enumerate(ids[u_indices])
                  },
                  "data": {
                      k: _tensor(v[idx][u_indices])
                      for k, v in n_data.data.items()
                  },
                  "dtype": ids.dtype,
              }
      return node_dict
  
imports: import ast
  import os
  from typing import Callable, List, Optional
  import numpy
  import pandas
  import pydantic
  import yaml
  from ..None import backend
  from ..base import dgl_warning, DGLError
  from ..convert import heterograph
label_desc: Use image node_id 3 for calling the NodeData obj's underlying member method code with example usage: obj.to_dict(node_data) and returns: node_dict