class_docstr: Composition of multiple `_RankingHead.
  
  The main functionality is to create an estimator spec that
    - merges all predictions from all heads.
    - merges all eval metrics from all heads.
    - combines all the losses using weights from all heads.
class_docstr_tok: ["Composition","of","multiple","`","_RankingHead",".","The","main","functionality","is","to","create","an","estimator","spec","that","-","merges","all","predictions","from","all","heads",".","-","merges","all","eval","metrics","from","all","heads",".","-","combines","all","the","losses","using","weights","from","all","heads","."]
docstr: Returns regularized training loss.
docstr_tok: ["Returns","regularized","training","loss","."]
code: def _merge_loss(
      self,
      labels,
      logits,
      features=None,
      mode=None,
      regularization_losses=None,
  ):
      """Returns regularized training loss."""
      self._check_logits_and_labels(logits, labels)
      training_losses = []
      for head in self._heads:
          training_loss = head.create_loss(
              logits=logits[head.name],
              labels=labels[head.name],
              features=features,
              mode=mode,
          )
          training_losses.append(training_loss)
      training_losses = tuple(training_losses)
  
      with tf.compat.v1.name_scope(
          "merge_losses",
          values=training_losses + (self._head_weights or tuple()),
      ):
          if self._head_weights:
              head_weighted_training_losses = []
              for training_loss, head_weight in zip(
                  training_losses, self._head_weights
              ):
                  head_weighted_training_losses.append(
                      tf.math.multiply(training_loss, head_weight)
                  )
              training_losses = head_weighted_training_losses
          merged_training_loss = tf.math.add_n(training_losses)
          regularization_loss = (
              tf.math.add_n(regularization_losses)
              if regularization_losses is not None
              else None
          )
          regularized_training_loss = (
              merged_training_loss + regularization_loss
              if regularization_loss is not None
              else merged_training_loss
          )
      return regularized_training_loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import six
  import tensorflow
  from tensorflow import estimator
label_desc: Use image node_id 5 for calling the _MultiRankingHead obj's underlying member method code with example usage: obj._merge_loss(labels, logits, features, mode, regularization_losses) and returns: regularized_training_loss