code: def _pairwise_hinge_loss(
      labels,
      logits,
      weights=None,
      lambda_weight=None,
      reduction=tf.compat.v1.losses.Reduction.SUM_BY_NONZERO_WEIGHTS,
      name=None,
  ):
      """Computes the pairwise hinge loss for a list.
  
      The hinge loss is defined as Hinge(l_i > l_j) = max(0, 1 - (s_i - s_j)). So a
      correctly ordered pair has 0 loss if (s_i - s_j >= 1). Otherwise the loss
      increases linearly with s_i - s_j. When the list_size is 2, this reduces to
      the standard hinge loss.
  
      Args:
        labels: A `Tensor` of the same shape as `logits` representing graded
          relevance.
        logits: A `Tensor` with shape [batch_size, list_size]. Each value is the
          ranking score of the corresponding item.
        weights: A scalar, a `Tensor` with shape [batch_size, 1] for list-wise
          weights, or a `Tensor` with shape [batch_size, list_size] for item-wise
          weights.
        lambda_weight: A `_LambdaWeight` object.
        reduction: One of `tf.losses.Reduction` except `NONE`. Describes how to
          reduce training loss over batch.
        name: A string used as the name for this loss.
  
      Returns:
        An op for the pairwise hinge loss.
      """
      loss = losses_impl.PairwiseHingeLoss(name, lambda_weight)
      with tf.compat.v1.name_scope(
          loss.name, "pairwise_hinge_loss", (labels, logits, weights)
      ):
          return loss.compute(labels, logits, weights, reduction)
  
imports: from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, Union
  import tensorflow
  from tensorflow_ranking.python import losses_impl
  from tensorflow_ranking.python import utils
label_desc: Use image node_id 6 for calling a global function with example usage: _pairwise_hinge_loss(labels, logits, weights, lambda_weight, reduction, name) and returns: loss