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: Similar to the `_get_node_attributes`
docstr_tok: ["Similar","to","the","`","_get_node_attributes","`"]
code: def _get_edge_attributes(self, key: str):
      r"""
      Similar to the `_get_node_attributes`
      """
      attributes = {}
      indices = None
      # TODO: suspect edge_to_tensor_mapping and edge_to_graph_mapping not useful
      if key == "edge_type":
          indices = {}
      for edge_idx, (head, tail, edge_dict) in enumerate(
          self.G.edges(data=True)
      ):
          if key in edge_dict:
              head_type = self.G.nodes[head]["node_type"]
              tail_type = self.G.nodes[tail]["node_type"]
              edge_type = self._get_edge_type(edge_dict)
              message_type = (head_type, edge_type, tail_type)
              if message_type not in attributes:
                  attributes[message_type] = []
              attributes[message_type].append(edge_dict[key])
              if indices is not None:
                  if message_type not in indices:
                      indices[message_type] = []
                  indices[message_type].append(edge_idx)
  
      if len(attributes) == 0:
          return None
  
      for message_type, val in attributes.items():
          if torch.is_tensor(attributes[message_type][0]):
              attributes[message_type] = torch.stack(val, dim=0)
          elif isinstance(attributes[message_type][0], float):
              attributes[message_type] = torch.tensor(
                  val, dtype=torch.float
              )
          elif isinstance(attributes[message_type][0], int):
              attributes[message_type] = torch.tensor(
                  val, dtype=torch.long
              )
          elif (
              isinstance(attributes[message_type][0], str)
              and key == "edge_type"
          ):
              continue
          else:
              raise TypeError(f"Unknown type {key} in edge attributes.")
          if self.is_undirected() and key != "edge_type":
              attributes[message_type] = torch.cat(
                  [attributes[message_type], attributes[message_type]],
                  dim=0,
              )
  
      if indices is not None:
          edge_to_tensor_mapping = torch.zeros(
              [
                  self.G.number_of_edges(),
              ],
              dtype=torch.int64,
          )
          for message_type in indices:
              indices[message_type] = torch.tensor(
                  indices[message_type], dtype=torch.int64
              )
              edge_to_tensor_mapping[
                  indices[message_type]
              ] = torch.arange(
                  len(indices[message_type]), dtype=torch.int64
              )
          self.edge_to_graph_mapping = indices
          self.edge_to_tensor_mapping = edge_to_tensor_mapping
  
      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 16 for calling the HeteroGraph obj's underlying member method code with example usage: obj._get_edge_attributes(key) and returns: attributes, None