class_docstr: Computes the self-adversarial binary cross entropy for negative sampling, from [1].
  
  [1] Z. Sun, Z.-H. Deng, J.-Y. Nie, and J. Tang, “RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space,” `arXiv:1902.10197 <http://arxiv.org/abs/1902.10197>`_
  
  Args:
      temperature (float, optional): a scaling factor for the weighting of negative samples
docstr: Args:
      labels: tensor of integer labels for each row, either 1 for a true sample, or any value <= 0 for negative samples. Negative samples with identical labels are combined for the softmax normalisation.
      logit_scores: tensor of scores for each row in logits
docstr_tok: ["Args",":","labels",":","tensor","of","integer","labels","for","each","row",",","either","1","for","a","true","sample",",","or","any","value","<","=","0","for","negative","samples",".","Negative","samples","with","identical","labels","are","combined","for","the","softmax","normalisation",".","logit_scores",":","tensor","of","scores","for","each","row","in","logits"]
code: def call(self, labels, logit_scores):
      """
      Args:
          labels: tensor of integer labels for each row, either 1 for a true sample, or any value <= 0 for negative samples. Negative samples with identical labels are combined for the softmax normalisation.
          logit_scores: tensor of scores for each row in logits
      """
  
      scores = tf.math.sigmoid(logit_scores)
  
      if labels.dtype != tf.int32:
          labels = tf.cast(labels, tf.int64)
  
      flipped_labels = -labels
  
      exp_scores = tf.math.exp(self._temperature * scores)
      sums = tf.math.unsorted_segment_sum(
          exp_scores, flipped_labels, tf.reduce_max(flipped_labels) + 1
      )
  
      denoms = tf.gather(sums, tf.maximum(flipped_labels, 0))
  
      # adversarial sampling shouldn't influence the gradient/update
      negative_weights = tf.stop_gradient(exp_scores / denoms)
  
      loss_elems = tf.where(
          labels > 0,
          -tf.math.log_sigmoid(logit_scores),
          -tf.math.log_sigmoid(-logit_scores) * negative_weights,
      )
  
      return tf.reduce_mean(loss_elems, axis=-1)
  
imports: import tensorflow
  from .core.experimental import experimental
label_desc: Use image node_id 2 for calling the SelfAdversarialNegativeSampling obj's underlying member method code with example usage: obj.call(labels, logit_scores) and returns: tf