code: def compute_loss_and_acc(
      self, model, lprobs, target, reduction="sum"
  ):
      if not lprobs.batch_first:
          lprobs = lprobs.transpose(0, 1)
      lprobs = lprobs.view(-1, lprobs.size(-1))  # -> (B x T) x C
      target = target.view(-1)
      loss, nll_loss = label_smoothed_nll_loss(
          lprobs,
          target,
          self.eps,
          ignore_index=self.padding_idx,
          reduce=(reduction == "sum"),
      )
  
      mask = target.ne(self.padding_idx)
      correct = torch.sum(
          lprobs.argmax(1)
          .masked_select(mask)
          .eq(target.masked_select(mask))
      )
      total = torch.sum(mask)
      return loss, nll_loss, correct, total
  
file_path: fairseq/examples/speech_text_joint_to_text/criterions/text_guide_cross_entropy_acc.py
imports: import math
  import torch
  import torch.nn.functional
  from fairseq import utils
  from fairseq.criterions import FairseqCriterion, register_criterion
  from fairseq.criterions.label_smoothed_cross_entropy import label_smoothed_nll_loss
  from fairseq.logging import metrics
label_desc: Use image node_id 4 for calling the GuidedCrossEntAccCriterion obj's underlying member method code with example usage: obj.compute_loss_and_acc(model, lprobs, target, reduction) and returns: loss,  nll_loss,  correct,  total