class_docstr: Computes a cross-entropy loss, normalized by the number of valid (non-pad) tokens.
  Uses an efficient implementation for label smoothing and avoids the obscure SoftmaxOutput op.
class_docstr_tok: ["Computes","a","cross-entropy","loss",",","normalized","by","the","number","of","valid","(","non-pad",")","tokens",".","Uses","an","efficient","implementation","for","label","smoothing","and","avoids","the","obscure","SoftmaxOutput","op","."]
code: def __init__(
      self,
      name: str = C.CROSS_ENTROPY,
      weight: float = 1.0,
      label_smoothing: float = 0.0,
      dtype: str = C.DTYPE_FP32,
      output_name: str = C.LOGITS_NAME,
      label_name: str = C.TARGET_LABEL_NAME,
      ignore_label: int = C.PAD_ID,
      metric_prefix: str = "",
      label_smoothing_impl: str = "mxnet",
  ) -> None:
      super().__init__(
          name=name,
          output_name=output_name,
          label_name=label_name,
          weight=weight,
          metric_prefix=metric_prefix,
      )
      self.ignore_label = ignore_label
      self._alpha = label_smoothing
      self._dtype = dtype
      self._reduction = "mean"  # TODO: consider sum reduction and normalization outside of loss for reporting
      if label_smoothing == 0 or label_smoothing_impl == "torch":
          self._ce_impl = self._torch_cross_entropy_loss
      elif label_smoothing > 0.0 and label_smoothing_impl == "mxnet":
          self._ce_impl = self._smoothed_loss_as_in_mxnet
      elif label_smoothing > 0.0 and label_smoothing_impl == "fairseq":
          self._ce_impl = self._smoothed_loss_as_in_fairseq
      else:
          raise ValueError(
              "unknown label_smoothing impl. choose from mxnet, fairseq, or torch."
          )
  
imports: import logging
  import math
  from abc import ABC, abstractmethod
  from typing import Any, Dict, Optional, Tuple
  import torch
  import numpy
  from .None import constants
  from .None import utils
label_desc: Use image node_id 1 to create a new CrossEntropyLoss object from inherited base classes: Loss with example: obj = CrossEntropyLoss(name, weight, label_smoothing, dtype, output_name, label_name, ignore_label, metric_prefix, label_smoothing_impl)