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: Extract the edge attributes indicated by edge_index in tensor backend.
docstr_tok: ["Extract","the","edge","attributes","indicated","by","edge_index","in","tensor","backend","."]
code: def _get_edge_attributes_by_key_tensor(self, edge_index, key: str):
      r"""
      Extract the edge attributes indicated by edge_index in tensor backend.
      """
      if not (
          isinstance(edge_index, dict)
          and all(
              isinstance(message, tuple)
              and torch.is_tensor(edge_index_message)
              for message, edge_index_message in edge_index.items()
          )
      ):
          raise TypeError("edge_index in not in the correct format.")
      if key == "edge_index":
          raise ValueError("edge_index cannot be selected.")
      if key not in self.keys or not isinstance(self[key], dict):
          return None
  
      attributes = {}
      for message_type in edge_index:
          attributes[message_type] = torch.index_select(
              self[key][message_type], 0, edge_index[message_type]
          )
          if self.is_undirected():
              attributes[message_type] = torch.cat(
                  [attributes[message_type], attributes[message_type]],
                  dim=0,
              )
  
      return attributes
  
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 27 for calling the HeteroGraph obj's underlying member method code with example usage: obj._get_edge_attributes_by_key_tensor(edge_index, key) and returns: attributes, None