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: Create edge label and the corresponding label_index (edges) for
  link prediction.
  
  Modifies the graph argument by setting the fields edge_label_index
  and edge_label.
docstr_tok: ["Create","edge","label","and","the","corresponding","label_index","(","edges",")","for","link","prediction",".","Modifies","the","graph","argument","by","setting","the","fields","edge_label_index","and","edge_label","."]
code: def _create_label_link_pred(self, graph, edges, nodes=None):
      r"""
      Create edge label and the corresponding label_index (edges) for
      link prediction.
  
      Modifies the graph argument by setting the fields edge_label_index
      and edge_label.
      """
      if self.G is not None:
          graph.edge_label_index = self._edge_to_index(edges, nodes)
          graph.edge_label = self._get_edge_attributes_by_key(
              edges,
              "edge_label",
          )
          graph._objective_edges = edges
      else:
          edge_label_index = {}
          for message_type in edges:
              edge_label_index[message_type] = torch.index_select(
                  self.edge_index[message_type], 1, edges[message_type]
              )
  
          # store objective edges
          graph._objective_edges = copy.deepcopy(edge_label_index)
  
          if self.is_undirected():
              for message_type in edge_label_index:
                  edge_label_index[message_type] = torch.cat(
                      [
                          edge_label_index[message_type],
                          torch.flip(
                              edge_label_index[message_type], [0]
                          ),
                      ],
                      dim=1,
                  )
  
          graph.edge_label_index = edge_label_index
          graph.edge_label = self._get_edge_attributes_by_key_tensor(
              edges, "edge_label"
          )
  
          # store objective edge attributes
          objective_edges_attribute = {}
          for key in graph.keys:
              if self._is_edge_attribute(key) and (key != "edge_label"):
                  edge_attribute = {}
                  for message_type in edges:
                      edge_attribute[message_type] = torch.index_select(
                          self[key][message_type],
                          0,
                          edges[message_type],
                      )
                  objective_edges_attribute[key] = edge_attribute
          graph._objective_edges_attribute = objective_edges_attribute
  
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 26 for calling the HeteroGraph obj's underlying member method code with example usage: obj._create_label_link_pred(graph, edges, nodes) without return types