class_docstr: Represent a single graph with additional attributes.
class_docstr_tok: ["Represent","a","single","graph","with","additional","attributes","."]
docstr: Set the features of the `nodes` with the given `new_data``.
  
  Parameters
  ----------
  nodes : int or slice
      The nodes involved
  new_data : dict
      The new data to write. Key indicates feature name and value indicates the
      actual value.
  
  Raises
  ----------
  SizeMismatchException
      If the size of the new features does not match the node number
code: def set_node_features(
      self, nodes: Union[int, slice], new_data: Dict[str, torch.Tensor]
  ) -> None:
      """
      Set the features of the `nodes` with the given `new_data``.
  
      Parameters
      ----------
      nodes : int or slice
          The nodes involved
      new_data : dict
          The new data to write. Key indicates feature name and value indicates the
          actual value.
  
      Raises
      ----------
      SizeMismatchException
          If the size of the new features does not match the node number
      """
      # Consistency check
      for key in new_data.keys():
          if (
              key not in self._node_features
              or self._node_features[key] is None
          ):  # A new feature is added
              # If the shape of the new feature does not match the number of
              # existing nodes, then error occurs
              if (not isinstance(nodes, slice)) or (
                  len(slice_to_list(nodes, self.get_node_num()))
                  != self.get_node_num()
              ):
                  raise ValueError(
                      "The new feature `{}' should cover all existing {} nodes!".format(
                          key, self.get_node_num()
                      )
                  )
  
      # Modification
      for key, value in new_data.items():
          # Node-shape check
          if not (value.shape[0] == self.get_node_num()):
              raise SizeMismatchException(
                  "The shape feature '{}' does not match the number of nodes in the graph."
                  "Got a {} tensor but have {} nodes.".format(
                      key, value.shape, self.get_node_num()
                  )
              )
          if not isinstance(value, torch.Tensor):
              raise TypeError(
                  "torch.Tensor expected, received `{}'.".format(
                      type(value)
                  )
              )
  
          value_on_device = value
          if (
              key not in self._node_features
              or self._node_features[key] is None
          ):
              self._node_features[key] = value_on_device
          else:
              if nodes == slice(None, None, None):
                  self._node_features[key] = value_on_device
              else:
                  self._node_features[key][nodes] = value_on_device
  
imports: import os
  import warnings
  from collections import namedtuple
  from typing import Any, Callable, Dict, List, Tuple, Union
  import dgl
  import scipy.sparse
  import torch
  from torch.nn.utils.rnn import pad_sequence
  from .utils import EdgeNotFoundException, SizeMismatchException, check_and_expand, entail_zero_padding, int_to_list, slice_to_list
  from .views import BatchEdgeFeatView, BatchNodeFeatView, EdgeView, NodeFeatView, NodeView
label_desc: Use image node_id 9 for calling the GraphData obj's underlying member method code with example usage: obj.set_node_features(nodes, new_data) without return types