code: def calculate_energy(self, src_emb, dst_emb, neg_emb, rel_emb):
      # expand true triplets embedding dims to fit corrupted trplets
      src_expand_emb = tf.tile(src_emb, [1, self.num_negs, 1])
      rel_expand_emb = tf.tile(rel_emb, [1, self.num_negs, 1])
      dst_expand_emb = tf.tile(dst_emb, [1, self.num_negs, 1])
  
      pos_scores = self.calculate_scores(src_emb, rel_emb, dst_emb)
      pos_scores = tf.reshape(pos_scores, [-1, 1, 1])
      if self.corrupt == "front":
          neg_scores = self.calculate_scores(
              neg_emb, rel_expand_emb, dst_expand_emb
          )
          neg_scores = tf.reshape(neg_scores, [-1, 1, self.num_negs])
      elif self.corrupt == "tail":
          neg_scores = self.calculate_scores(
              src_expand_emb, rel_expand_emb, neg_emb
          )
          neg_scores = tf.reshape(neg_scores, [-1, 1, self.num_negs])
      else:
          front_neg_scores = self.calculate_scores(
              neg_emb, rel_expand_emb, dst_expand_emb
          )
          tail_neg_scores = self.calculate_scores(
              src_expand_emb, rel_expand_emb, neg_emb
          )
          neg_scores = tf.reshape(
              tf.concat([front_neg_scores, tail_neg_scores], axis=-1),
              [-1, 1, self.num_negs * 2],
          )
  
      loss = self.loss_fn(pos_scores, neg_scores)
      if self.metric_name == "mrr":
          metric = self._mrr(pos_scores, neg_scores)
      elif self.metric_name == "mr":
          metric = self._mr(pos_scores, neg_scores)
      elif self.metric_name == "hit10":
          metric = self._hit10(pos_scores, neg_scores)
      else:
          msg = "Metric name :{} not in list [mrr, mr, hit10]".format(
              self.metric_name
          )
          raise ValueError(msg)
      return loss, metric
  
file_path: euler/examples/TransX/transX.py
imports: import tensorflow
  import tf_euler
  import collections
label_desc: Use image node_id 10 for calling the TransX obj's underlying member method code with example usage: obj.calculate_energy(src_emb, dst_emb, neg_emb, rel_emb) and returns: loss,  metric