class_docstr: Extension of Transresnet to incorporate dialogue history and multimodality.
docstr: Compute loss over batch.
  
  :param total_encoded:
      encoding of the examples
  :param labels_encoded:
      encoding of the labels
  
  :return:
      total batch loss, and number of correct examples
docstr_tok: ["Compute","loss","over","batch",".",":","param","total_encoded",":","encoding","of","the","examples",":","param","labels_encoded",":","encoding","of","the","labels",":","return",":","total","batch","loss",",","and","number","of","correct","examples"]
code: def get_loss(self, total_encoded, labels_encoded):
      """
      Compute loss over batch.
  
      :param total_encoded:
          encoding of the examples
      :param labels_encoded:
          encoding of the labels
  
      :return:
          total batch loss, and number of correct examples
      """
      loss = None
      num_correct = None
      if labels_encoded is not None:
          dot_products = total_encoded.mm(
              labels_encoded.t()
          )  # batch_size * batch_size
          log_prob = torch.nn.functional.log_softmax(
              dot_products, dim=1
          )
          targets = torch.arange(
              0, len(total_encoded), dtype=torch.long
          )
          if self.use_cuda:
              targets = targets.cuda()
          loss = torch.nn.functional.nll_loss(log_prob, targets)
          num_correct = (
              (log_prob.max(dim=1)[1] == targets).float().sum()
          )
      return loss, num_correct
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import torch
  from torch import nn
  from parlai.utils.io import PathManager
  from parlai.agents.transformer.modules import TransformerEncoder, create_position_codes, TransformerEncoderLayer
  from projects.personality_captions.transresnet.modules import TransresnetModel, load_fasttext_embeddings
label_desc: Use image node_id 12 for calling the TransresnetMultimodalModel obj's underlying member method code with example usage: obj.get_loss(total_encoded, labels_encoded) and returns: loss,  num_correct