class_docstr: loss util unittest
docstr: test cross entropy
docstr_tok: ["test","cross","entropy"]
code: def test_cross_entropy(self):
      """test cross entropy"""
      with self.cached_session():
          loss = loss_utils.cross_entropy(
              logits=tf.constant(self.logits),
              input_length=None,
              labels=tf.constant(self.labels),
              label_length=None,
          )
          self.assertAllClose(loss.eval(), 0.0, rtol=1e-06, atol=1.5e-6)
  
          loss_2 = loss_utils.cross_entropy(
              logits=tf.constant(self.logits_2),
              labels=tf.constant(self.labels),
          )
          self.assertAllClose(
              loss_2.eval(), 6.5194526, rtol=1e-06, atol=1.5e-6
          )
  
          loss = loss_utils.cross_entropy(
              logits=tf.constant(self.seq_logits),
              input_length=tf.constant(self.input_length),
              labels=tf.constant(self.seq_labels),
              label_length=tf.constant(self.label_length),
              reduction=tf.losses.Reduction.NONE,
          )
          self.assertEqual(loss.eval().shape, (2, 3))
          self.assertAllClose(
              loss.eval(),
              np.zeros((2, 3), dtype=np.float32),
              rtol=1e-06,
              atol=1.5e-6,
          )
  
          loss = loss_utils.cross_entropy(
              logits=tf.constant(self.seq_logits),
              input_length=tf.constant(self.input_length),
              labels=tf.constant(self.seq_labels),
              label_length=tf.constant(self.label_length),
              reduction=tf.losses.Reduction.SUM_BY_NONZERO_WEIGHTS,
          )
          self.assertEqual(loss.eval().shape, ())
          self.assertAllClose(loss.eval(), 0.0, rtol=1e-06, atol=1.5e-6)
  
file_path: delta/delta/utils/loss/loss_utils_test.py
imports: import numpy
  import delta.compat
  from absl import logging
  from delta.utils.loss import loss_utils
label_desc: Use image node_id 3 for calling the LossUtilTest obj's underlying member method code with example usage: obj.test_cross_entropy() without return types