class_docstr: RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space.
  https://arxiv.org/abs/1902.10197
class_docstr_tok: ["RotatE",":","Knowledge","Graph","Embedding","by","Relational","Rotation","in","Complex","Space",".","https",":","\/\/arxiv.org\/abs\/1902.10197"]
code: def get_neg_score(self, head, rel, tail, neg_head=False):
      num_chunks = head.shape[0]
  
      if neg_head:
          chunk_size = tail.shape[1]
          neg_sample_size = head.shape[1]
  
          re_tail, im_tail = paddle.chunk(tail, chunks=2, axis=-1)
          phase_rel = rel / (self.emb_init / np.pi)
          re_rel, im_rel = paddle.cos(phase_rel), paddle.sin(phase_rel)
  
          re_score = re_rel * re_tail + im_rel * im_tail
          im_score = re_rel * im_tail - im_rel * re_tail
          score = paddle.concat([re_score, im_score], axis=-1)
          score = paddle.reshape(score, [num_chunks, chunk_size, 1, -1])
          head = paddle.reshape(
              head, [num_chunks, 1, neg_sample_size, -1]
          )
  
          score = paddle.tile(
              score, repeat_times=[1, 1, neg_sample_size, 1]
          )
          head = paddle.tile(head, repeat_times=[1, chunk_size, 1, 1])
  
          score = score - head
          re_score, im_score = paddle.chunk(score, chunks=2, axis=-1)
  
          score = paddle.sqrt(
              re_score * re_score + im_score * im_score + self.epsilon
          )
          score = self.gamma - paddle.sum(score, axis=-1)
      else:
          chunk_size = head.shape[1]
          neg_sample_size = tail.shape[1]
  
          re_head, im_head = paddle.chunk(head, chunks=2, axis=-1)
          phase_rel = rel / (self.emb_init / np.pi)
          re_rel, im_rel = paddle.cos(phase_rel), paddle.sin(phase_rel)
  
          re_score = re_rel * re_head - im_rel * im_head
          im_score = re_rel * im_head + im_rel * re_head
          score = paddle.concat([re_score, im_score], axis=-1)
          score = paddle.reshape(score, [num_chunks, chunk_size, 1, -1])
          tail = paddle.reshape(
              tail, [num_chunks, 1, neg_sample_size, -1]
          )
  
          score = paddle.tile(
              score, repeat_times=[1, 1, neg_sample_size, 1]
          )
          tail = paddle.tile(tail, repeat_times=[1, chunk_size, 1, 1])
  
          score = score - tail
          re_score, im_score = paddle.chunk(score, chunks=2, axis=-1)
  
          score = paddle.sqrt(
              re_score * re_score + im_score * im_score + self.epsilon
          )
          score = self.gamma - paddle.sum(score, axis=-1)
  
      return score
  
imports: import math
  import numpy
  from numpy.random import RandomState
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.functional import log_sigmoid
label_desc: Use image node_id 4 for calling the RotatEScore obj's underlying member method code with example usage: obj.get_neg_score(head, rel, tail, neg_head) and returns: score