class_docstr: Attention net. See file docstring.
class_docstr_tok: ["Attention","net",".","See","file","docstring","."]
docstr: Auxiliary predict loss.
  
  Args:
    body_output: Tensor with shape [batch_size, decoder_length, hidden_dim].
    features: Map of features to the model. Must contain the following:
        "targets": Target decoder outputs.
            [batch_size, decoder_length, 1, hidden_dim]
    shift: int != 0, amount to shift/pad the target sequence.
      If shift > 0, it represents the number of previous timesteps to
      reconstruct; if shift < 0, it represents the number of future timesteps
      to predict.
  
  Returns:
    A 2-tuple of the numerator and denominator of the cross-entropy loss.
  
  Raises:
    ValueError: if features does not contain a targets_raw tensor.
docstr_tok: ["Auxiliary","predict","loss",".","Args",":","body_output",":","Tensor","with","shape","[","batch_size",",","decoder_length",",","hidden_dim","]",".","features",":","Map","of","features","to","the","model",".","Must","contain","the","following",":","``","targets","''",":","Target","decoder","outputs",".","[","batch_size",",","decoder_length",",","1",",","hidden_dim","]","shift",":","int","!","=","0",",","amount","to","shift\/pad","the","target","sequence",".","If","shift",">","0",",","it","represents","the","number","of","previous","timesteps","to","reconstruct",";","if","shift","<","0",",","it","represents","the","number","of","future","timesteps","to","predict",".","Returns",":","A","2-tuple","of","the","numerator","and","denominator","of","the","cross-entropy","loss",".","Raises",":","ValueError",":","if","features","does","not","contain","a","targets_raw","tensor","."]
code: def auxiliary_loss(self, body_output, features, shift):
      """Auxiliary predict loss.
  
      Args:
        body_output: Tensor with shape [batch_size, decoder_length, hidden_dim].
        features: Map of features to the model. Must contain the following:
            "targets": Target decoder outputs.
                [batch_size, decoder_length, 1, hidden_dim]
        shift: int != 0, amount to shift/pad the target sequence.
          If shift > 0, it represents the number of previous timesteps to
          reconstruct; if shift < 0, it represents the number of future timesteps
          to predict.
  
      Returns:
        A 2-tuple of the numerator and denominator of the cross-entropy loss.
  
      Raises:
        ValueError: if features does not contain a targets_raw tensor.
      """
      assert isinstance(shift, int) and shift != 0
      name = (
          "reconst_%d" % shift
          if shift > 0
          else "predict_%d" % abs(shift)
      )
  
      if features and "targets_raw" in features:
          targets = features["targets_raw"]
          targets = common_layers.flatten4d3d(targets)
      else:
          raise ValueError(
              "Feature map must contain a targets_raw tensor."
          )
  
      with tf.variable_scope(name):
          logits = self.top(body_output, features)
          labels = shift_and_pad(targets, shift, axis=1)
          return common_layers.padded_cross_entropy(
              logits, labels, self._hparams.label_smoothing
          )
  
file_path: tensor2tensor/tensor2tensor/models/research/transformer_aux.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.layers import common_layers
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the TransformerAux obj's underlying member method code with example usage: obj.auxiliary_loss(body_output, features, shift) and returns: common_layers