code: def weighted_focal_sigmoid_cross_entropy(
      logits: jnp.ndarray,
      multi_hot_targets: jnp.ndarray,
      weights: Optional[jnp.ndarray] = None,
      label_weights: Optional[jnp.ndarray] = None,
      label_smoothing: Optional[float] = None,
      alpha: Optional[float] = 0.5,
      gamma: Optional[float] = 2.0,
  ) -> jnp.ndarray:
      """Computes weighted focal sigmoid cross entropy given logits and targets.
  
      Args:
        logits: Output of model in shape [batch, ..., num_classes].
        multi_hot_targets: Multi-hot vector of shape [batch, ..., num_classes].
        weights: None or array of shape [batch, ...] (rank of one_hot_targets -1).
        label_weights: None or array of shape broadcastable to the shape of logits.
          Typically this would be [num_classes] and is the weight to apply to each
          label.
        label_smoothing: Scalar to use to smooth the one-hot labels.
        alpha: Focal loss parameter alpha.
        gamma: Focal loss parameter gamma.
  
      Returns:
        The mean focal loss of the examples in the given batch as a scalar.
      """
      if weights is not None:
          normalization = weights.sum()
      else:
          normalization = np.prod(multi_hot_targets.shape[:-1])
  
      unnormalized_sigmoid_ce = model_utils.focal_sigmoid_cross_entropy(
          logits,
          multi_hot_targets,
          weights=weights,
          label_weights=label_weights,
          label_smoothing=label_smoothing,
          alpha=alpha,
          gamma=gamma,
      )
      return jnp.sum(unnormalized_sigmoid_ce) / (normalization + 1e-8)
  
imports: import functools
  from typing import Any, Callable, Dict, Mapping, Optional, Tuple, Union
  import immutabledict
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import model_utils
  from scenic.projects.unloc import metrics
label_desc: Use image node_id 6 for calling a global function with example usage: weighted_focal_sigmoid_cross_entropy(logits, multi_hot_targets, weights, label_weights, label_smoothing, alpha, gamma) and returns: unknown