class_docstr: Sequence-to-sequence base class.
class_docstr_tok: ["Sequence-to-sequence","base","class","."]
docstr: Compute softmax loss or sampled softmax loss.
docstr_tok: ["Compute","softmax","loss","or","sampled","softmax","loss","."]
code: def _softmax_cross_entropy_loss(
      self, logits, decoder_cell_outputs, labels
  ):
      """Compute softmax loss or sampled softmax loss."""
      if self.num_sampled_softmax > 0:
          is_sequence = decoder_cell_outputs.shape.ndims == 3
  
          if is_sequence:
              labels = tf.reshape(labels, [-1, 1])
              inputs = tf.reshape(
                  decoder_cell_outputs, [-1, self.num_units]
              )
  
          crossent = tf.nn.sampled_softmax_loss(
              weights=tf.transpose(self.output_layer.kernel),
              biases=self.output_layer.bias
              or tf.zeros([self.tgt_vocab_size]),
              labels=labels,
              inputs=inputs,
              num_sampled=self.num_sampled_softmax,
              num_classes=self.tgt_vocab_size,
              partition_strategy="div",
              seed=self.random_seed,
          )
  
          if is_sequence:
              if self.time_major:
                  crossent = tf.reshape(crossent, [-1, self.batch_size])
              else:
                  crossent = tf.reshape(crossent, [self.batch_size, -1])
  
      else:
          crossent = tf.nn.sparse_softmax_cross_entropy_with_logits(
              labels=labels, logits=logits
          )
  
      return crossent
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import collections
  import tensorflow
  from tensorflow.contrib.model_pruning import get_masks, get_thresholds
  from tensorflow.contrib.model_pruning.python import pruning
  from tensorflow.contrib.model_pruning.python.layers import core_layers
  from .None import model_helper
  from .utils import misc_utils, iterator_utils
label_desc: Use image node_id 18 for calling the BaseModel obj's underlying member method code with example usage: obj._softmax_cross_entropy_loss(logits, decoder_cell_outputs, labels) and returns: crossent