class_docstr: loss util unittest
code: def test_focal_loss(self):
      with self.cached_session():
          logits = np.array([[22, 23, 24]], dtype=np.float32)
          labels = np.array([2], dtype=np.int32)
          alpha = tf.ones([3])
  
          ce_loss = loss_utils.cross_entropy(
              logits=tf.constant(logits),
              input_length=None,
              labels=tf.constant(labels),
              label_length=None,
          )
  
          fl_loss0 = loss_utils.focal_loss(
              logits=tf.constant(logits),
              labels=tf.constant(labels),
              alpha=alpha,
              gamma=0,
          )
  
          self.assertAllClose(
              fl_loss0.eval(), 0.407606, rtol=1e-06, atol=1e-6
          )
          self.assertAllClose(
              fl_loss0.eval(), ce_loss.eval(), rtol=1e-07, atol=1e-7
          )
  
          fl_loss2 = loss_utils.focal_loss(
              logits=tf.constant(logits),
              labels=tf.constant(labels),
              alpha=alpha,
              gamma=2,
          )
  
          fl_loss5 = loss_utils.focal_loss(
              logits=tf.constant(logits),
              labels=tf.constant(labels),
              alpha=alpha,
              gamma=5,
          )
  
          self.assertAllClose(
              fl_loss2.eval(), 0.045677, rtol=1e-06, atol=1e-6
          )
          self.assertAllClose(
              fl_loss5.eval(), 0.001713, rtol=1e-06, atol=1e-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 8 for calling the LossUtilTest obj's underlying member method code with example usage: obj.test_focal_loss() without return types