code: def weighted_unnormalized_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,
      logits_normalized: bool = False,
  ) -> jnp.ndarray:
      """Computes weighted sigmoid cross entropy given logits and targets.
  
      This also called Binary Cross-Entropy Loss and it measures the probability
      error in discrete classification tasks in which each class is independent and
      not mutually exclusive.
      This computes sum_(x,y) sigmoid-ce(x, y) for a single, potentially padded
      minibatch. If the minibatch is padded (that is it contains null examples)
      it is assumed that weights is a binary mask where 0 indicates that the
      example is null.
  
      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 x ...] (rank of one_hot_targets -1).
          This is the weight to apply to the loss computed for each example in the
          batch. Can be used to ignore padded examples in the batch.
        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.
        logits_normalized: If True, the logits are assumed to be log probs.
  
      Returns:
        The sigmoid cross entropy of the examples in the given batch.
      """
      if logits.ndim != multi_hot_targets.ndim:
          raise ValueError(
              "Incorrect shapes. Got shape %s logits and %s multi_hot_targets"
              % (str(logits.shape), str(multi_hot_targets.shape))
          )
  
      # Optionally apply label smoothing.
      if label_smoothing is not None:
          multi_hot_targets = apply_label_smoothing(
              multi_hot_targets, label_smoothing
          )
  
      if logits_normalized:
          log_p, prob = logits, jnp.exp(logits)
          log_not_p = jnp.log((1 + 1e-6) - prob)
      else:
          log_p, log_not_p = jax.nn.log_sigmoid(
              logits
          ), jax.nn.log_sigmoid(-logits)
  
      loss = -(
          multi_hot_targets * log_p
          + (1.0 - multi_hot_targets) * log_not_p
      )
  
      if label_weights is not None:
          loss = loss * label_weights
  
      if weights is not None:
          loss = apply_weights(loss, weights)
  
      return loss
  
imports: import functools
  from typing import Optional, Any, Tuple, Union
  import flax.linen
  import jax
  import jax.numpy
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: weighted_unnormalized_sigmoid_cross_entropy(logits, multi_hot_targets, weights, label_weights, label_smoothing, logits_normalized) and returns: loss