class_docstr: Test various loss functions in model_utils.
class_docstr_tok: ["Test","various","loss","functions","in","model_utils","."]
docstr: Tests focal_sigmoid_cross_entropy.
docstr_tok: ["Tests","focal_sigmoid_cross_entropy","."]
code: def test_focal_sigmoid_cross_entropy(self):
      """Tests focal_sigmoid_cross_entropy."""
      logits = jnp.array([[1, 2, 3], [4, 5, 6]], dtype=jnp.float32)
      labels = jnp.array([[0, 1, 1], [1, 0, 1]], dtype=jnp.float32)
      sigmoid = jax.nn.sigmoid
      log = jnp.log
  
      a = 0.25
      g = 2.0
      loss = model_utils.focal_sigmoid_cross_entropy(
          logits, labels, alpha=a, gamma=g
      )
  
      gt_loss = jnp.array(
          [
              [
                  -log(1 - sigmoid(1.0)),
                  -log(sigmoid(2.0)),
                  -log(sigmoid(3.0)),
              ],
              [
                  -log(sigmoid(4.0)),
                  -log(1 - sigmoid(5.0)),
                  -log(sigmoid(6.0)),
              ],
          ]
      )
      focal_factor = jnp.array(
          [
              [
                  (1 - a) * sigmoid(1.0) ** g,
                  a * sigmoid(-2.0) ** g,
                  a * sigmoid(-3.0) ** g,
              ],
              [
                  a * sigmoid(-4.0) ** g,
                  (1 - a) * sigmoid(5.0) ** g,
                  a * sigmoid(-6.0) ** g,
              ],
          ]
      )
      self.assertSequenceAlmostEqual(
          loss.flatten(), (gt_loss * focal_factor).flatten(), places=3
      )
  
imports: import itertools
  from absl.testing import absltest
  from absl.testing import parameterized
  from flax.training import common_utils
  import jax
  import jax.numpy
  import numpy
  from scenic.model_lib.base_models import model_utils
label_desc: Use image node_id 4 for calling the LossTest obj's underlying member method code with example usage: obj.test_focal_sigmoid_cross_entropy() without return types