class_docstr: CrossEntropyLoss
class_docstr_tok: ["CrossEntropyLoss"]
docstr: Args:
      logits (float): output of the classifier
      labels (long): ground truth labels
      loss_mask (bool/float/int): tensor to specify the masking
docstr_tok: ["Args",":","logits","(","float",")",":","output","of","the","classifier","labels","(","long",")",":","ground","truth","labels","loss_mask","(","bool\/float\/int",")",":","tensor","to","specify","the","masking"]
code: def forward(self, logits, labels, loss_mask=None):
      """
      Args:
          logits (float): output of the classifier
          labels (long): ground truth labels
          loss_mask (bool/float/int): tensor to specify the masking
      """
      logits_flatten = torch.flatten(logits, start_dim=0, end_dim=-2)
      labels_flatten = torch.flatten(labels, start_dim=0, end_dim=-1)
  
      if loss_mask is not None:
          if loss_mask.dtype is not torch.bool:
              loss_mask = loss_mask > 0.5
          loss_mask_flatten = torch.flatten(
              loss_mask, start_dim=0, end_dim=-1
          )
          logits_flatten = logits_flatten[loss_mask_flatten]
          labels_flatten = labels_flatten[loss_mask_flatten]
  
      if len(labels_flatten) == 0:
          return super().forward(logits, torch.argmax(logits, dim=-1))
  
      loss = super().forward(logits_flatten, labels_flatten)
      return loss
  
imports: import torch
  from torch import nn
  from nemo.core.classes import Serialization, Typing, typecheck
  from nemo.core.neural_types import LabelsType, LogitsType, LogprobsType, LossType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling the CrossEntropyLoss obj's underlying member method code with example usage: obj.forward(logits, labels, loss_mask) and returns: loss, super