class_docstr: FID model.
class_docstr_tok: ["FID","model","."]
docstr: Returns negative loglikelihood (NLL) of the target sentence.
  
  Args:
    output: Output of model in OrderedDict.
    batch: Batch of data that has 'decoder_target' as ground-truth.
  
  Returns:
    Total loss.
docstr_tok: ["Returns","negative","loglikelihood","(","NLL",")","of","the","target","sentence",".","Args",":","output",":","Output","of","model","in","OrderedDict",".","batch",":","Batch","of","data","that","has","'decoder_target","'","as","ground-truth",".","Returns",":","Total","loss","."]
code: def loss_function_dict(
      self, output: constants.JTensorDict, batch: constants.JTensorDict
  ) -> Dict[str, Any]:
      """Returns negative loglikelihood (NLL) of the target sentence.
  
      Args:
        output: Output of model in OrderedDict.
        batch: Batch of data that has 'decoder_target' as ground-truth.
  
      Returns:
        Total loss.
      """
      gen_loss = losses.nll_loss(
          targets=batch["decoder_target_tokens"],
          pred=output["predicted_logits"],
          target_masks=batch["decoder_target_tokens"] > 0,
          label_smoothing=self.config.model.get("label_smoothing"),
      )
      loss_dict = {"gen_loss": gen_loss}
      if output["supervised_retrieval"]:
          retr_loss, (retr_acc, s0, s1) = losses.contrastive_loss(
              query_emb=output["base_query"],
              key_emb=output["retr_keys"],
              temperature=self.config.model.get("temperature"),
          )
          loss_dict["retr_loss"] = retr_loss
          loss_dict["retr_acc"] = retr_acc
          loss_dict["s0"] = s0
          loss_dict["s1"] = s1
      else:
          loss_dict["retr_loss"] = -1
          loss_dict["retr_acc"] = -1
          loss_dict["s0"] = -1
          loss_dict["s1"] = -1
      return loss_dict
  
imports: from typing import Any, Dict, Optional
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  from scenic.model_lib.base_models import base_model
  from scenic.projects.knowledge_visual_language.models import constants
  from scenic.projects.knowledge_visual_language.models import layers
  from scenic.projects.knowledge_visual_language.models import losses
  from scenic.projects.knowledge_visual_language.models import metrics
  from scenic.projects.knowledge_visual_language.models import vit
  from scenic.projects.t5 import layers
  from scenic.projects.t5 import model
label_desc: Use image node_id 2 for calling the FIDSoftModel obj's underlying member method code with example usage: obj.loss_function_dict(output, batch) and returns: loss_dict