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 _torch_cross_entropy_loss(self, logits, labels):
      logits = logits.view(-1, logits.size()[-1])
      # Reshape due to: view size is not compatible with input tensor's size and stride
      # (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
      labels = labels.reshape(-1)
      _kwargs = {
          "weight": None,
          "ignore_index": self.ignore_label,
          "reduction": self._reduction,
      }
      if self._alpha > 0.0:
          _kwargs["label_smoothing"] = self._alpha
      ce = pt.nn.functional.cross_entropy(
          logits, labels.long(), **_kwargs
      )
      ce *= self.weight
      return ce
  
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 4 for calling the CrossEntropyLoss obj's underlying member method code with example usage: obj._torch_cross_entropy_loss(logits, labels) and returns: ce