class_docstr: Shallow models for knowledge representation learning.
      
docstr: Compute scores of given candidates.
          
code: def predict(self, ent, rel, cand=None, mode="tail"):
      """Compute scores of given candidates."""
      self.set_eval_mode()
      if cand is None:
          cand_emb = paddle.to_tensor(
              self.ent_embedding.weight
          ).unsqueeze(0)
          if self._use_feat:
              cand_feat = paddle.to_tensor(
                  self._ent_feat.astype("float32")
              )
              cand_emb = self.trans_ent(cand_feat, cand_emb)
          cand_emb = cand_emb.tile([ent.shape[0], 1, 1])
      else:
          num_cand = cand.shape[1]
          cand_emb = self._get_ent_embedding(
              cand.reshape(
                  [
                      -1,
                  ]
              )
          )
          cand_emb = cand_emb.reshape([-1, num_cand, self._ent_dim])
  
      ent_emb = self._get_ent_embedding(ent)
      rel_emb = self._get_rel_embedding(rel)
      ent_emb = paddle.unsqueeze(ent_emb, axis=1)
      rel_emb = paddle.unsqueeze(rel_emb, axis=1)
  
      if mode == "tail":
          scores = self._score_func.get_neg_score(
              ent_emb, rel_emb, cand_emb, False
          )
      else:
          scores = self._score_func.get_neg_score(
              cand_emb, rel_emb, ent_emb, True
          )
      scores = paddle.squeeze(scores, axis=1)
      return scores
  
imports: import os
  import json
  import math
  import warnings
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from pgl.utils.shared_embedding import SharedEmbedding
  from models.score_funcs import TransEScore, RotatEScore, DistMultScore, ComplExScore, QuatEScore, OTEScore
  from models.init_func import InitFunction
  from utils import uniform, timer_wrapper
label_desc: Use image node_id 10 for calling the KGEModel obj's underlying member method code with example usage: obj.predict(ent, rel, cand, mode) and returns: scores