code: def add_nodes(g, num, data=None, ntype=None):
      r"""Add the given number of nodes to the graph and return a new graph.
  
      The new nodes will have IDs starting from ``g.num_nodes(ntype)``.
  
      Parameters
      ----------
      num : int
          The number of nodes to add.
      data : dict[str, Tensor], optional
          Feature data of the added nodes. The keys are feature names
          while the values are feature data.
      ntype : str, optional
          The node type name. Can be omitted if there is
          only one type of nodes in the graph.
  
      Return
      ------
      DGLGraph
          The graph with newly added nodes.
  
      Notes
      -----
      * For features in :attr:`g` but not in :attr:`data`,
        DGL assigns zero features for the newly added nodes.
      * For feature in :attr:`data` but not in :attr:`g`, DGL assigns zero features
        for the existing nodes in the graph.
      * This function discards the batch information. Please use
        :func:`dgl.DGLGraph.set_batch_num_nodes`
        and :func:`dgl.DGLGraph.set_batch_num_edges` on the transformed graph
        to maintain the information.
  
      Examples
      --------
  
      The following example uses PyTorch backend.
  
      >>> import dgl
      >>> import torch
  
      **Homogeneous Graphs**
  
      >>> g = dgl.graph((torch.tensor([0, 1]), torch.tensor([1, 2])))
      >>> g.num_nodes()
      3
      >>> g = dgl.add_nodes(g, 2)
      >>> g.num_nodes()
      5
  
      If the graph has some node features and new nodes are added without
      features, their features will be filled with zeros.
  
      >>> g.ndata['h'] = torch.ones(5, 1)
      >>> g = dgl.add_nodes(g, 1)
      >>> g.ndata['h']
      tensor([[1.], [1.], [1.], [1.], [1.], [0.]])
  
      Assign features for the new nodes.
  
      >>> g = dgl.add_nodes(g, 1, {'h': torch.ones(1, 1), 'w': torch.ones(1, 1)})
      >>> g.ndata['h']
      tensor([[1.], [1.], [1.], [1.], [1.], [0.], [1.]])
  
      Since :attr:`data` contains new feature fields, the features for existing nodes
      will be filled with zeros.
  
      >>> g.ndata['w']
      tensor([[0.], [0.], [0.], [0.], [0.], [0.], [1.]])
  
      **Heterogeneous Graphs**
  
      >>> g = dgl.heterograph({
      ...     ('user', 'plays', 'game'): (torch.tensor([0, 1, 1, 2]),
      ...                                 torch.tensor([0, 0, 1, 1])),
      ...     ('developer', 'develops', 'game'): (torch.tensor([0, 1]),
      ...                                         torch.tensor([0, 1]))
      ...     })
      >>> g.num_nodes('user')
      3
      >>> g = dgl.add_nodes(g, 2, ntype='user')
      >>> g.num_nodes('user')
      5
  
      See Also
      --------
      remove_nodes
      add_edges
      remove_edges
      """
      g = g.clone()
      g.add_nodes(num, data=data, ntype=ntype)
      return g
  
imports: import copy
  from collections.abc import Iterable, Mapping
  import numpy
  import scipy.sparse
  import scipy.sparse.linalg
  from ..utils import version
  from ..None import backend, batch, convert, function, ndarray, subgraph, utils
  from .._ffi.function import _init_api
  from ..base import dgl_warning, DGLError, EID, NID
  from ..frame import Frame
  from ..heterograph import DGLGraph
  from ..heterograph_index import create_heterograph_from_relations, create_metagraph_index
  from ..partition import metis_partition, metis_partition_assignment, partition_graph_with_halo
  from ..sampling.neighbor import sample_neighbors
label_desc: Use image node_id 17 for calling a global function with example usage: add_nodes(g, num, data, ntype) and returns: g