class_docstr: Adapts T2TModel for sequential_scheduled_sampling().
class_docstr_tok: ["Adapts","T2TModel","for","sequential_scheduled_sampling","(",")","."]
docstr: Constructs loss dict.
  
  Args:
    targets: [batch_size, seq_len]
    logits: [batch_size, seq_len, vocab_size]
  
  Returns:
    {str: Tensor of shape []}. Losses.
docstr_tok: ["Constructs","loss","dict",".","Args",":","targets",":","[","batch_size",",","seq_len","]","logits",":","[","batch_size",",","seq_len",",","vocab_size","]","Returns",":","{","str",":","Tensor","of","shape","[","]","}",".","Losses","."]
code: def loss_fn(self, targets, logits):
      """Constructs loss dict.
  
      Args:
        targets: [batch_size, seq_len]
        logits: [batch_size, seq_len, vocab_size]
  
      Returns:
        {str: Tensor of shape []}. Losses.
      """
      batch_size, seq_len, vocab_size = common_layers.shape_list(logits)
      targets = tf.reshape(targets, [batch_size, seq_len, 1, 1])
      logits = tf.reshape(
          logits, [batch_size, seq_len, 1, 1, vocab_size]
      )
      features = copy.copy(self._features)
      features["targets"] = targets
  
      with tf.variable_scope(tf.get_variable_scope(), reuse=True):
          losses = {
              "training": self._t2tmodel.loss(logits, features),
          }
  
      return losses
  
file_path: tensor2tensor/tensor2tensor/utils/scheduled_sampling.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  from tensor2tensor.layers import common_layers
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.python.ops import inplace_ops
label_desc: Use image node_id 4 for calling the ScheduledSamplingAdapter obj's underlying member method code with example usage: obj.loss_fn(targets, logits) and returns: losses