class_docstr: Node embedding application.
  
  Given a graph, it embeds each node into a continuous vector representation.
  The learned embeddings can be used for many downstream tasks.
  e.g. **node classification**, **link prediction**, **node analogy**.
  The similarity between node embeddings can be measured by cosine distance.
  
  Supported Models:
      - DeepWalk (`DeepWalk: Online Learning of Social Representations`_)
      - LINE (`LINE: Large-scale Information Network Embedding`_)
      - node2vec (`node2vec: Scalable Feature Learning for Networks`_)
  
  .. _DeepWalk\: Online Learning of Social Representations:
      https://arxiv.org/pdf/1403.6652.pdf
  .. _LINE\: Large-scale Information Network Embedding:
      https://arxiv.org/pdf/1503.03578.pdf
  .. _node2vec\: Scalable Feature Learning for Networks:
      https://www.kdd.org/kdd2016/papers/files/rfp0218-groverA.pdf
  
  Parameters:
      dim (int): dimension of embeddings
      gpus (list of int, optional): GPU ids, default is all GPUs
      cpu_per_gpu (int, optional): number of CPU threads per GPU, default is all CPUs
      float_type (dtype, optional): type of parameters
      index_type (dtype, optional): type of graph indexes
  
  See also:
      :class:`Graph <graphvite.graph.Graph>`,
      :class:`GraphSolver <graphvite.solver.GraphSolver>`
class_docstr_tok: ["Node","embedding","application",".","Given","a","graph",",","it","embeds","each","node","into","a","continuous","vector","representation",".","The","learned","embeddings","can","be","used","for","many","downstream","tasks",".","e.g",".","*","*","node","classification","*","*",",","*","*","link","prediction","*","*",",","*","*","node","analogy","*","*",".","The","similarity","between","node","embeddings","can","be","measured","by","cosine","distance",".","Supported","Models",":","-","DeepWalk","(","`","DeepWalk",":","Online","Learning","of","Social","Representations","`","_",")","-","LINE","(","`","LINE",":","Large-scale","Information","Network","Embedding","`","_",")","-","node2vec","(","`","node2vec",":","Scalable","Feature","Learning","for","Networks","`","_",")","..","_DeepWalk\\",":","Online","Learning","of","Social","Representations",":","https",":","\/\/arxiv.org\/pdf\/1403.6652.pdf","..","_LINE\\",":","Large-scale","Information","Network","Embedding",":","https",":","\/\/arxiv.org\/pdf\/1503.03578.pdf","..","_node2vec\\",":","Scalable","Feature","Learning","for","Networks",":","https",":","\/\/www.kdd.org\/kdd2016\/papers\/files\/rfp0218-groverA.pdf","Parameters",":","dim","(","int",")",":","dimension","of","embeddings","gpus","(","list","of","int",",","optional",")",":","GPU","ids",",","default","is","all","GPUs","cpu_per_gpu","(","int",",","optional",")",":","number","of","CPU","threads","per","GPU",",","default","is","all","CPUs","float_type","(","dtype",",","optional",")",":","type","of","parameters","index_type","(","dtype",",","optional",")",":","type","of","graph","indexes","See","also",":",":","class",":","`","Graph","<","graphvite.graph.Graph",">","`",",",":","class",":","`","GraphSolver","<","graphvite.solver.GraphSolver",">","`"]
docstr: Evaluate node embeddings on link prediction task.
  
  Parameters:
      H (list of str, optional): names of head nodes
      T (list of str, optional): names of tail nodes
      Y (list of int, optional): labels of edges
      file_name (str, optional): file of edges and labels (e.g. validation set)
      filter_H (list of str, optional): names of head nodes to filter out
      filter_T (list of str, optional): names of tail nodes to filter out
      filter_file (str, optional): file of edges to filter out (e.g. training set)
  
  Returns:
      dict: AUC of link prediction
docstr_tok: ["Evaluate","node","embeddings","on","link","prediction","task",".","Parameters",":","H","(","list","of","str",",","optional",")",":","names","of","head","nodes","T","(","list","of","str",",","optional",")",":","names","of","tail","nodes","Y","(","list","of","int",",","optional",")",":","labels","of","edges","file_name","(","str",",","optional",")",":","file","of","edges","and","labels","(","e.g",".","validation","set",")","filter_H","(","list","of","str",",","optional",")",":","names","of","head","nodes","to","filter","out","filter_T","(","list","of","str",",","optional",")",":","names","of","tail","nodes","to","filter","out","filter_file","(","str",",","optional",")",":","file","of","edges","to","filter","out","(","e.g",".","training","set",")","Returns",":","dict",":","AUC","of","link","prediction"]
code: def link_prediction(
      self,
      H=None,
      T=None,
      Y=None,
      file_name=None,
      filter_H=None,
      filter_T=None,
      filter_file=None,
  ):
      """
      Evaluate node embeddings on link prediction task.
  
      Parameters:
          H (list of str, optional): names of head nodes
          T (list of str, optional): names of tail nodes
          Y (list of int, optional): labels of edges
          file_name (str, optional): file of edges and labels (e.g. validation set)
          filter_H (list of str, optional): names of head nodes to filter out
          filter_T (list of str, optional): names of tail nodes to filter out
          filter_file (str, optional): file of edges to filter out (e.g. training set)
  
      Returns:
          dict: AUC of link prediction
      """
      import torch
  
      from .network import LinkPredictor
  
      self.solver.clear()
  
      if file_name:
          if not (H is None and T is None and Y is None):
              raise ValueError(
                  "Evaluation data and file should not be provided at the same time"
              )
          H = []
          T = []
          Y = []
          with open(file_name, "r") as fin:
              for line in fin:
                  tokens = self.tokenize(line)
                  if len(tokens) == 0:
                      continue
                  h, t, y = tokens
                  H.append(h)
                  T.append(t)
                  Y.append(y)
      if H is None or T is None or Y is None:
          raise ValueError(
              "Either evaluation data or file should be provided"
          )
  
      if filter_file:
          if not (filter_H is None and filter_T is None):
              raise ValueError(
                  "Filter data and file should not be provided at the same time"
              )
          filter_H = []
          filter_T = []
          with open(filter_file, "r") as fin:
              for line in fin:
                  tokens = self.tokenize(line)
                  if len(tokens) == 0:
                      continue
                  h, t = tokens
                  filter_H.append(h)
                  filter_T.append(t)
      elif filter_H is None:
          filter_H = []
          filter_T = []
  
      name2id = self.graph.name2id
      Y = [int(y) for y in Y]
      new_H, new_T, new_Y = self.name_map(
          (name2id, name2id, {0: 0, 1: 1}), (H, T, Y)
      )
      logger.info("effective edges: %d / %d" % (len(new_H), len(H)))
      H = new_H
      T = new_T
      Y = new_Y
      new_H, new_T = self.name_map(
          (name2id, name2id), (filter_H, filter_T)
      )
      logger.info(
          "effective filter edges: %d / %d"
          % (len(new_H), len(filter_H))
      )
      filters = set(zip(new_H, new_T))
      new_H = []
      new_T = []
      new_Y = []
      for h, t, y in zip(H, T, Y):
          if (h, t) not in filters:
              new_H.append(h)
              new_T.append(t)
              new_Y.append(y)
      logger.info("remaining edges: %d / %d" % (len(new_H), len(H)))
      H = np.asarray(new_H)
      T = np.asarray(new_T)
      Y = np.asarray(new_Y)
  
      vertex_embeddings = self.solver.vertex_embeddings
      context_embeddings = self.solver.context_embeddings
      model = LinkPredictor(
          self.solver.model, vertex_embeddings, context_embeddings
      )
      model = model.cuda()
  
      H = torch.as_tensor(H)
      T = torch.as_tensor(T)
      Y = torch.as_tensor(Y)
      H = H.cuda()
      T = T.cuda()
      Y = Y.cuda()
      score = model(H, T)
      order = torch.argsort(score, descending=True)
      Y = Y[order]
      hit = torch.cumsum(Y, dim=0)
      all = torch.sum(Y == 0) * torch.sum(Y == 1)
      auc = torch.sum(hit[Y == 0]).item() / all.item()
  
      return {"AUC": auc}
  
imports: from __future__ import print_function, absolute_import, unicode_literals, division
  import os
  import re
  import pickle
  import logging
  import multiprocessing
  from collections import defaultdict
  from future.builtins import str, map, range
  from easydict import EasyDict
  import numpy
  from ..None import lib, cfg, auto
  from ..None import graph, solver
  from ..util import assert_in, monitor, SharedNDArray
label_desc: Use image node_id 5 for calling the GraphApplication obj's underlying member method code with example usage: obj.link_prediction(H, T, Y, file_name, filter_H, filter_T, filter_file) and returns: dict