class_docstr: Pairwise, max-margin loss.
  
  Introduced in :cite:`bordes2013translating`.
  
  .. math::
  
      \mathcal{L}(\Theta) = \sum_{t^+ \in \mathcal{G}}\sum_{t^- \in \mathcal{C}}max(0, [\gamma + f_{model}(t^-;\Theta)
       - f_{model}(t^+;\Theta)])
  
  where :math:`\gamma` is the margin, :math:`\mathcal{G}` is the set of positives,
  :math:`\mathcal{C}` is the set of corruptions, :math:`f_{model}(t;\Theta)` is the model-specific scoring function.
  
  Example
  -------
  >>> import ampligraph.latent_features.loss_functions as lfs
  >>> loss = lfs.PairwiseLoss({'margin': 0.005, 'reduction': 'sum'})
  >>> isinstance(loss, lfs.PairwiseLoss)
  True
  
  >>> loss = lfs.get('pairwise')
  >>> isinstance(loss, lfs.PairwiseLoss)
  True
class_docstr_tok: ["Pairwise",",","max-margin","loss",".","Introduced","in",":","cite",":","`","bordes2013translating","`",".","..","math",":",":","\\mathcal","{","L","}","(","\\Theta",")","=","\\sum_","{","t^+","\\in","\\mathcal","{","G","}","}","\\sum_","{","t^-","\\in","\\mathcal","{","C","}","}","max","(","0",",","[","\\gamma","+","f_","{","model","}","(","t^-",";","\\Theta",")","-","f_","{","model","}","(","t^+",";","\\Theta",")","]",")","where",":","math",":","`","\\gamma","`","is","the","margin",",",":","math",":","`","\\mathcal","{","G","}","`","is","the","set","of","positives",",",":","math",":","`","\\mathcal","{","C","}","`","is","the","set","of","corruptions",",",":","math",":","`","f_","{","model","}","(","t",";","\\Theta",")","`","is","the","model-specific","scoring","function",".","Example","--","--","--","-",">",">",">","import","ampligraph.latent_features.loss_functions","as","lfs",">",">",">","loss","=","lfs.PairwiseLoss","(","{","'margin","'",":","0.005",",","'reduction","'",":","'sum","'","}",")",">",">",">","isinstance","(","loss",",","lfs.PairwiseLoss",")","True",">",">",">","loss","=","lfs.get","(","'pairwise","'",")",">",">",">","isinstance","(","loss",",","lfs.PairwiseLoss",")","True"]
docstr: Apply the loss function.
  
  Parameters
  ----------
  scores_pos : tf.Tensor, shape (n, 1)
      A tensor of scores assigned to positive statements.
  scores_neg : tf.Tensor, shape (n, 1)
      A tensor of scores assigned to negative statements.
  
  Returns
  -------
  loss : tf.Tensor
      The loss value that must be minimized.
docstr_tok: ["Apply","the","loss","function",".","Parameters","--","--","--","--","--","scores_pos",":","tf.Tensor",",","shape","(","n",",","1",")","A","tensor","of","scores","assigned","to","positive","statements",".","scores_neg",":","tf.Tensor",",","shape","(","n",",","1",")","A","tensor","of","scores","assigned","to","negative","statements",".","Returns","--","--","--","-","loss",":","tf.Tensor","The","loss","value","that","must","be","minimized","."]
code: def _apply_loss(self, scores_pos, scores_neg):
      """Apply the loss function.
  
      Parameters
      ----------
      scores_pos : tf.Tensor, shape (n, 1)
          A tensor of scores assigned to positive statements.
      scores_neg : tf.Tensor, shape (n, 1)
          A tensor of scores assigned to negative statements.
  
      Returns
      -------
      loss : tf.Tensor
          The loss value that must be minimized.
  
      """
      margin = tf.constant(
          self._loss_parameters["margin"],
          dtype=tf.float32,
          name="margin",
      )
      loss = self._reduce_sample_loss(
          tf.maximum(margin - scores_pos + scores_neg, 0)
      )
      return loss
  
imports: import abc
  import logging
  import six
  import tensorflow
  from tensorflow.python.keras import metrics
  from tensorflow.python.keras.utils import losses_utils
  from tensorflow.python.ops import math_ops
label_desc: Use image node_id 3 for calling the PairwiseLoss obj's underlying member method code with example usage: obj._apply_loss(scores_pos, scores_neg) and returns: loss