class_docstr: Represent a single graph with additional attributes.
class_docstr_tok: ["Represent","a","single","graph","with","additional","attributes","."]
docstr: Set edge feature
  
  Parameters
  ----------
  edges : int or list or slice
      Edge indices
  new_data : dict
      New data
  
  Raises
  ----------
  SizeMismatchException
      If the size of the new features does not match the node number
code: def set_edge_feature(
      self,
      edges: Union[int, slice, List[int]],
      new_data: Dict[str, torch.Tensor],
  ):
      """
      Set edge feature
  
      Parameters
      ----------
      edges : int or list or slice
          Edge indices
      new_data : dict
          New data
  
      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._edge_features
              or self._edge_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(edges, slice)
                  or len(slice_to_list(edges, self.get_edge_num()))
                  != self.get_edge_num()
              ):
                  raise SizeMismatchException(
                      "The new feature `{}' should cover all existing {} edges!".format(
                          key, self.get_edge_num()
                      )
                  )
  
      # Modification
      for key, value in new_data.items():
          if not isinstance(value, torch.Tensor):
              raise TypeError(
                  "'{}' is not a tensor. Node features are expected to be tensor.".format(
                      value
                  )
              )
          if not (value.shape[0] == self.get_edge_num()):
              raise SizeMismatchException(
                  "Length of the feature vector does not match the edge number."
                  "Got tensor '{}' of shape {} but the graph has only {} edges.".format(
                      key, value.shape, self.get_edge_num()
                  )
              )
          # Move the new value to the device consistent with current graph
          value_on_device = value.to(self.device)
  
          if (
              key not in self._edge_features
              or self._edge_features[key] is None
          ):
              self._edge_features[key] = value_on_device
          elif edges == slice(None, None, None):
              # Same as node features, if the edges to be modified is all the edges in the graph.
              self._edge_features[key] = value_on_device
          else:
              self._edge_features[key][edges] = 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 22 for calling the GraphData obj's underlying member method code with example usage: obj.set_edge_feature(edges, new_data) without return types