code: def compute_cross_entropy_loss(logits, targets, ignore_index=-100):
      """
      Function to compute the cross entropy loss. The default value of
      ignore_index is the same as the default value for F.cross_entropy in
      pytorch.
      """
      assert logits.size(0) == targets.size(
          -1
      ), "Logits and Targets tensor shapes don't match up"
  
      loss = F.nll_loss(
          F.log_softmax(logits, -1, dtype=torch.float32),
          targets,
          reduction="sum",
          ignore_index=ignore_index,
      )
      return loss
  
file_path: fairseq/fairseq/criterions/legacy_masked_lm.py
imports: import math
  import torch
  import torch.nn.functional
  from fairseq import utils
  from fairseq.logging import metrics
  from fairseq.criterions import FairseqCriterion, register_criterion
label_desc: Use image node_id 1 for calling a global function with example usage: compute_cross_entropy_loss(logits, targets, ignore_index) and returns: loss