class_docstr: Sparsemax loss function.
  
  Computes the generalized multi-label classification loss for the sparsemax
  function.
  
  Because the sparsemax loss function needs both the probability output and
  the logits to compute the loss value, `from_logits` must be `True`.
  
  Because it computes the generalized multi-label loss, the shape of both
  `y_pred` and `y_true` must be `[batch_size, num_classes]`.
  
  Args:
    from_logits: Whether `y_pred` is expected to be a logits tensor. Default
      is `True`, meaning `y_pred` is the logits.
    reduction: (Optional) Type of `tf.keras.losses.Reduction` to apply to
      loss. Default value is `SUM_OVER_BATCH_SIZE`.
    name: Optional name for the op.
code: def __init__(
      self,
      from_logits: bool = True,
      reduction: str = tf.keras.losses.Reduction.SUM_OVER_BATCH_SIZE,
      name: str = "sparsemax_loss",
  ):
      if from_logits is not True:
          raise ValueError("from_logits must be True")
  
      super().__init__(name=name, reduction=reduction)
      self.from_logits = from_logits
  
file_path: addons/tensorflow_addons/losses/sparsemax_loss.py
imports: import tensorflow
  from tensorflow_addons.activations.sparsemax import sparsemax
  from tensorflow_addons.utils.types import TensorLike
  from typeguard import typechecked
  from typing import Optional
label_desc: Use image node_id 1 to create a new SparsemaxLoss object from inherited base classes: tf.keras.losses with example: obj = SparsemaxLoss(from_logits, reduction, name)