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: List of G.edges to dictionary of torch tensor edge_index
  
  Only the selected edges' edge indices are extracted.
  
  Returns:
      :class:`torch.tensor`: Edge indices.
docstr_tok: ["List","of","G.edges","to","dictionary","of","torch","tensor","edge_index","Only","the","selected","edges","'","edge","indices","are","extracted",".","Returns",":",":","class",":","`","torch.tensor","`",":","Edge","indices","."]
code: def _edge_to_index(self, edges, nodes):
      r"""
      List of G.edges to dictionary of torch tensor edge_index
  
      Only the selected edges' edge indices are extracted.
  
      Returns:
          :class:`torch.tensor`: Edge indices.
      """
      edge_index = {}
      nodes_dict = {}
      for node in nodes:
          nodes_dict[node[0]] = node[1]["node_type"]
  
      for idx, edge in enumerate(edges):
          if isinstance(edge_index, dict):
              edge_type = self._get_edge_type(edge[-1])
              head_type = nodes_dict[edge[0]]
              tail_type = nodes_dict[edge[1]]
              message_type = (head_type, edge_type, tail_type)
  
              if message_type not in edge_index:
                  edge_index[message_type] = []
              edge_index[message_type].append((edge[0], edge[1]))
  
      for key in edge_index:
          edge_index[key] = torch.tensor(edge_index[key])
  
      if self.is_undirected():
          for key in edge_index:
              edge_index[key] = torch.cat(
                  [edge_index[key], torch.flip(edge_index[key], [1])],
                  dim=0,
              )
  
      for key in edge_index:
          permute_tensor = edge_index[key].permute(1, 0)
          source_node_index = self._convert_to_tensor_index(
              permute_tensor[0]
          )
          target_node_index = self._convert_to_tensor_index(
              permute_tensor[1]
          )
          edge_index[key] = torch.stack(
              [source_node_index, target_node_index]
          )
  
      return edge_index
  
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 19 for calling the HeteroGraph obj's underlying member method code with example usage: obj._edge_to_index(edges, nodes) and returns: edge_index