docstr: ivy.Container instance method variant of ivy.sparse_cross_entropy.
  This method simply wraps the function, and so the docstring for
  ivy.sparse_cross_entropy also applies to this method with minimal
  changes.
  
  Parameters
  ----------
  self
      input container containing the true labels as logits.
  pred
      input array or container containing the predicted labels as logits.
  axis
      the axis along which to compute the cross-entropy. If axis is ``-1``, the
      cross-entropy will be computed along the last dimension. Default: ``-1``.
      epsilon
      a float in [0.0, 1.0] specifying the amount of smoothing when calculating
      the loss. If epsilon is ``0``, no smoothing will be applied.
      Default: ``1e-7``.
  key_chains
      The key-chains to apply or not apply the method to. Default is ``None``.
  to_apply
      If True, the method will be applied to key_chains, otherwise key_chains
      will be skipped. Default is ``True``.
  prune_unapplied
      Whether to prune key_chains for which the function was not applied.
      Default is ``False``.
  map_sequences
      Whether to also map method to sequences (lists, tuples).
      Default is ``False``.
  out
      optional output container, for writing the result to. It must have a shape
      that the inputs broadcast to.
  
  Returns
  -------
  ret
      The sparse cross-entropy loss between the given distributions.
  
  Examples
  --------
  >>> x = ivy.Container(a=ivy.array([1, 0, 0]),b=ivy.array([0, 0, 1]))
  >>> y = ivy.Container(a=ivy.array([0.6, 0.2, 0.3]),b=ivy.array([0.8, 0.2, 0.2]))
  >>> z = x.sparse_cross_entropy(y)
  >>> print(z)
  {
      a: ivy.array([1.61, 0.511, 0.511]),
      b: ivy.array([0.223, 0.223, 1.61])
  }
docstr_tok: ["ivy.Container","instance","method","variant","of","ivy.sparse_cross_entropy",".","This","method","simply","wraps","the","function",",","and","so","the","docstring","for","ivy.sparse_cross_entropy","also","applies","to","this","method","with","minimal","changes",".","Parameters","--","--","--","--","--","self","input","container","containing","the","true","labels","as","logits",".","pred","input","array","or","container","containing","the","predicted","labels","as","logits",".","axis","the","axis","along","which","to","compute","the","cross-entropy",".","If","axis","is","``","-1","``",",","the","cross-entropy","will","be","computed","along","the","last","dimension",".","Default",":","``","-1","``",".","epsilon","a","float","in","[","0.0",",","1.0","]","specifying","the","amount","of","smoothing","when","calculating","the","loss",".","If","epsilon","is","``","0","``",",","no","smoothing","will","be","applied",".","Default",":","``","1e-7","``",".","key_chains","The","key-chains","to","apply","or","not","apply","the","method","to",".","Default","is","``","None","``",".","to_apply","If","True",",","the","method","will","be","applied","to","key_chains",",","otherwise","key_chains","will","be","skipped",".","Default","is","``","True","``",".","prune_unapplied","Whether","to","prune","key_chains","for","which","the","function","was","not","applied",".","Default","is","``","False","``",".","map_sequences","Whether","to","also","map","method","to","sequences","(","lists",",","tuples",")",".","Default","is","``","False","``",".","out","optional","output","container",",","for","writing","the","result","to",".","It","must","have","a","shape","that","the","inputs","broadcast","to",".","Returns","--","--","--","-","ret","The","sparse","cross-entropy","loss","between","the","given","distributions",".","Examples","--","--","--","--",">",">",">","x","=","ivy.Container","(","a=ivy.array","(","[","1",",","0",",","0","]",")",",","b=ivy.array","(","[","0",",","0",",","1","]",")",")",">",">",">","y","=","ivy.Container","(","a=ivy.array","(","[","0.6",",","0.2",",","0.3","]",")",",","b=ivy.array","(","[","0.8",",","0.2",",","0.2","]",")",")",">",">",">","z","=","x.sparse_cross_entropy","(","y",")",">",">",">","print","(","z",")","{","a",":","ivy.array","(","[","1.61",",","0.511",",","0.511","]",")",",","b",":","ivy.array","(","[","0.223",",","0.223",",","1.61","]",")","}"]
code: def sparse_cross_entropy(
      self: ivy.Container,
      pred: Union[ivy.Container, ivy.Array, ivy.NativeArray],
      /,
      *,
      axis: Union[int, ivy.Container] = -1,
      epsilon: Union[float, ivy.Container] = 1e-7,
      reduction: Union[str, ivy.Container] = "mean",
      key_chains: Optional[
          Union[List[str], Dict[str, str], ivy.Container]
      ] = None,
      to_apply: Union[bool, ivy.Container] = True,
      prune_unapplied: Union[bool, ivy.Container] = False,
      map_sequences: Union[bool, ivy.Container] = False,
      out: Optional[ivy.Container] = None,
  ) -> ivy.Container:
      """ivy.Container instance method variant of ivy.sparse_cross_entropy.
      This method simply wraps the function, and so the docstring for
      ivy.sparse_cross_entropy also applies to this method with minimal
      changes.
  
      Parameters
      ----------
      self
          input container containing the true labels as logits.
      pred
          input array or container containing the predicted labels as logits.
      axis
          the axis along which to compute the cross-entropy. If axis is ``-1``, the
          cross-entropy will be computed along the last dimension. Default: ``-1``.
          epsilon
          a float in [0.0, 1.0] specifying the amount of smoothing when calculating
          the loss. If epsilon is ``0``, no smoothing will be applied.
          Default: ``1e-7``.
      key_chains
          The key-chains to apply or not apply the method to. Default is ``None``.
      to_apply
          If True, the method will be applied to key_chains, otherwise key_chains
          will be skipped. Default is ``True``.
      prune_unapplied
          Whether to prune key_chains for which the function was not applied.
          Default is ``False``.
      map_sequences
          Whether to also map method to sequences (lists, tuples).
          Default is ``False``.
      out
          optional output container, for writing the result to. It must have a shape
          that the inputs broadcast to.
  
      Returns
      -------
      ret
          The sparse cross-entropy loss between the given distributions.
  
      Examples
      --------
      >>> x = ivy.Container(a=ivy.array([1, 0, 0]),b=ivy.array([0, 0, 1]))
      >>> y = ivy.Container(a=ivy.array([0.6, 0.2, 0.3]),b=ivy.array([0.8, 0.2, 0.2]))
      >>> z = x.sparse_cross_entropy(y)
      >>> print(z)
      {
          a: ivy.array([1.61, 0.511, 0.511]),
          b: ivy.array([0.223, 0.223, 1.61])
      }
      """
      return self._static_sparse_cross_entropy(
          self,
          pred,
          axis=axis,
          epsilon=epsilon,
          reduction=reduction,
          key_chains=key_chains,
          to_apply=to_apply,
          prune_unapplied=prune_unapplied,
          map_sequences=map_sequences,
          out=out,
      )
  
file_path: ivy/ivy/data_classes/container/losses.py
imports: from typing import Optional, Union, List, Dict
  import ivy
  from ivy.data_classes.container.base import ContainerBase
label_desc: Use image node_id 6 for calling the _ContainerWithLosses obj's underlying member method code with example usage: obj.sparse_cross_entropy() and returns: self