class_docstr: DGL Knowledge Embedding Model.
  
  Parameters
  ----------
  args:
      Global configs.
  model_name : str
      Which KG model to use, including 'TransE_l1', 'TransE_l2', 'TransR',
      'RESCAL', 'DistMult', 'ComplEx', 'RotatE', 'SimplE'
  n_entities : int
      Num of entities.
  n_relations : int
      Num of relations.
  hidden_dim : int
      Dimension size of embedding.
  gamma : float
      Gamma for score function.
  double_entity_emb : bool
      If True, entity embedding size will be 2 * hidden_dim.
      Default: False
  double_relation_emb : bool
      If True, relation embedding size will be 2 * hidden_dim.
      Default: False
docstr: Do the forward.
  
  Parameters
  ----------
  pos_g : DGLGraph
      Graph holding positive edges.
  neg_g : DGLGraph
      Graph holding negative edges.
  gpu_id : int
      Which gpu to accelerate the calculation. if -1 is provided, cpu is used.
  
  Returns
  -------
  tensor
      loss value
  dict
      loss info
docstr_tok: ["Do","the","forward",".","Parameters","--","--","--","--","--","pos_g",":","DGLGraph","Graph","holding","positive","edges",".","neg_g",":","DGLGraph","Graph","holding","negative","edges",".","gpu_id",":","int","Which","gpu","to","accelerate","the","calculation",".","if","-1","is","provided",",","cpu","is","used",".","Returns","--","--","--","-","tensor","loss","value","dict","loss","info"]
code: def forward(self, pos_g, neg_g, gpu_id=-1):
      """Do the forward.
  
      Parameters
      ----------
      pos_g : DGLGraph
          Graph holding positive edges.
      neg_g : DGLGraph
          Graph holding negative edges.
      gpu_id : int
          Which gpu to accelerate the calculation. if -1 is provided, cpu is used.
  
      Returns
      -------
      tensor
          loss value
      dict
          loss info
      """
      # print(gpu_id, self.transform_net.transform_e_net.weight)
      if self.encoder_model_name == "roberta":
          pos_g.ndata["emb"] = self.transform_net.embed_entity(
              self.entity_feat(pos_g.ndata["id"], gpu_id, False)
          )
          pos_g.edata["emb"] = self.transform_net.embed_relation(
              self.relation_feat(pos_g.edata["id"], gpu_id, False)
          )
      elif self.encoder_model_name == "shallow":
          pos_g.ndata["emb"] = self.entity_emb(
              pos_g.ndata["id"], gpu_id, True
          )
          pos_g.edata["emb"] = self.relation_emb(
              pos_g.edata["id"], gpu_id, True
          )
      elif self.encoder_model_name == "concat":
          pos_g.ndata["emb"] = self.transform_net.embed_entity(
              torch.cat(
                  [
                      self.entity_feat(
                          pos_g.ndata["id"], gpu_id, False
                      ),
                      self.entity_emb(pos_g.ndata["id"], gpu_id, True),
                  ],
                  -1,
              )
          )
          pos_g.edata["emb"] = self.transform_net.embed_relation(
              torch.cat(
                  [
                      self.relation_feat(
                          pos_g.edata["id"], gpu_id, False
                      ),
                      self.relation_emb(
                          pos_g.edata["id"], gpu_id, True
                      ),
                  ],
                  -1,
              )
          )
      self.score_func.prepare(pos_g, gpu_id, True)
      pos_score = self.predict_score(pos_g)
      if gpu_id >= 0:
          neg_score = self.predict_neg_score(
              pos_g,
              neg_g,
              to_device=cuda,
              gpu_id=gpu_id,
              trace=True,
              neg_deg_sample=self.args.neg_deg_sample,
          )
      else:
          neg_score = self.predict_neg_score(
              pos_g,
              neg_g,
              trace=True,
              neg_deg_sample=self.args.neg_deg_sample,
          )
  
      neg_score = reshape(neg_score, -1, neg_g.neg_sample_size)
      # subsampling weight
      # TODO: add subsampling to new sampler
      # if self.args.non_uni_weight:
      #    subsampling_weight = pos_g.edata['weight']
      #    pos_score = (pos_score * subsampling_weight).sum() / subsampling_weight.sum()
      #    neg_score = (neg_score * subsampling_weight).sum() / subsampling_weight.sum()
      # else:
      edge_weight = (
          F.copy_to(pos_g.edata["impts"], get_dev(gpu_id))
          if self.has_edge_importance
          else None
      )
      loss, log = self.loss_gen.get_total_loss(
          pos_score, neg_score, edge_weight
      )
      # regularization: TODO(zihao)
      # TODO: only reg ent&rel embeddings. other params to be added.
      if (
          self.args.regularization_coef > 0.0
          and self.args.regularization_norm > 0
          and self.encoder_model_name in ["concat", "shallow"]
      ):
          coef, nm = (
              self.args.regularization_coef,
              self.args.regularization_norm,
          )
          reg = coef * (
              norm(self.entity_emb.curr_emb(), nm)
              + norm(self.relation_emb.curr_emb(), nm)
          )
          log["regularization"] = get_scalar(reg)
          loss = loss + reg
  
      return loss, log
  
imports: import os
  import numpy
  import math
  import dgl.backend
  import pdb
  import torch
  import torch.nn
  from .pytorch.tensor_models import logsigmoid
  from .pytorch.tensor_models import abs
  from .pytorch.tensor_models import masked_select
  from .pytorch.tensor_models import get_device, get_dev
  from .pytorch.tensor_models import norm
  from .pytorch.tensor_models import get_scalar
  from .pytorch.tensor_models import reshape
  from .pytorch.tensor_models import cuda
  from .pytorch.tensor_models import ExternalEmbedding
  from .pytorch.tensor_models import InferEmbedding
  from .pytorch.score_fun import *
  from .pytorch.loss import LossGenerator
label_desc: Use image node_id 10 for calling the KEModel obj's underlying member method code with example usage: obj.forward(pos_g, neg_g, gpu_id) and returns: loss,  log