class_docstr: A plain python object modeling a heterogeneous graph with various
  attributes (Node types in :class:`HeteroGraph` require string type).
  
  Args:
      G (:class:`networkx.classes.graph`): A NetworkX graph object which
          contains features and labels for each node type and edge type.
      **kwargs: Keyworded argument list with keys such
          as :obj:`"node_feature"`, :obj:`"node_label"` and
          corresponding attributes.
class_docstr_tok: ["A","plain","python","object","modeling","a","heterogeneous","graph","with","various","attributes","(","Node","types","in",":","class",":","`","HeteroGraph","`","require","string","type",")",".","Args",":","G","(",":","class",":","`","networkx.classes.graph","`",")",":","A","NetworkX","graph","object","which","contains","features","and","labels","for","each","node","type","and","edge","type",".","*","*","kwargs",":","Keyworded","argument","list","with","keys","such","as",":","obj",":","`","``","node_feature","''","`",",",":","obj",":","`","``","node_label","''","`","and","corresponding","attributes","."]
docstr: Update attributes and indices with values from the self.G
docstr_tok: ["Update","attributes","and","indices","with","values","from","the","self.G"]
code: def _update_index(self, init: bool = False):
      r"""
      Update attributes and indices with values from the self.G
      """
      if self.G is not None:
          keys = list(self.G.nodes)
          vals = range(sum(self.num_nodes().values()))
          mapping = dict(zip(keys, vals))
          self.G = nx.relabel_nodes(self.G, mapping, copy=True)
          self.edge_index = self._edge_to_index(
              list(self.G.edges(data=True)),
              list(self.G.nodes(data=True)),
          )
      else:
          mapping = {
              x: x for x in range(sum(self.num_nodes().values()))
          }
      if init:
          self.edge_label_index = copy.deepcopy(self.edge_index)
          self.node_label_index = {}
          for node_type in self.node_types:
              self.node_label_index[node_type] = torch.arange(
                  self.num_nodes(node_type), dtype=torch.long
              )
  
          self._custom_update(mapping)
  
imports: import math
  import copy
  import random
  import torch
  import networkx
  import numpy
  from deepsnap.graph import Graph
  from typing import Dict, List, Union
  import warnings
label_desc: Use image node_id 17 for calling the HeteroGraph obj's underlying member method code with example usage: obj._update_index(init) without return types