class_docstr: RPA UL Agent.
  
  Performs unlikelihood such that tokens which lead to misclassification are
  penalized.
class_docstr_tok: ["RPA","UL","Agent",".","Performs","unlikelihood","such","that","tokens","which","lead","to","misclassification","are","penalized","."]
docstr: Comptue UL Loss.
  
  :param pred_toks:
      predicted tokens from model
  :param label_mask:
      tokens to apply loss to
  :logits:
      token scores from model
  
  :return ul_loss:
      return the UL loss.
docstr_tok: ["Comptue","UL","Loss",".",":","param","pred_toks",":","predicted","tokens","from","model",":","param","label_mask",":","tokens","to","apply","loss","to",":","logits",":","token","scores","from","model",":","return","ul_loss",":","return","the","UL","loss","."]
code: def compute_ul_loss(
      self,
      pred_toks: torch.LongTensor,
      label_mask: torch.Tensor,
      logits: torch.Tensor,
  ) -> torch.Tensor:
      """
      Comptue UL Loss.
  
      :param pred_toks:
          predicted tokens from model
      :param label_mask:
          tokens to apply loss to
      :logits:
          token scores from model
  
      :return ul_loss:
          return the UL loss.
      """
      clamp_min = 1e-6 if self.opt["fp16"] else 1e-20
      lprobs = self.pred_logsoftmax(logits)
      pred_lprobs = lprobs.view(-1, lprobs.size(2)).gather(
          1, pred_toks.view(-1, 1)
      )
      one_minus_probs = torch.clamp(
          (1.0 - pred_lprobs.exp()), min=clamp_min
      ).view(pred_toks.size(0), pred_toks.size(1))
      loss = -torch.log(one_minus_probs) * label_mask
      return loss
  
imports: from typing import Optional, List, Tuple
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.torch_agent import Batch
  import torch
  import torch.nn
  import torch.nn.functional
  from parlai.agents.transformer.transformer import TransformerGeneratorAgent
  from parlai.core.torch_agent import Output
  from parlai.core.metrics import AverageMetric
  from projects.light_whoami.agents.rpa_rerank import RPAReranker
  from projects.msc.agents.long_tga import TransformerVariantAgent
label_desc: Use image node_id 5 for calling the RpaUlAgent obj's underlying member method code with example usage: obj.compute_ul_loss(pred_toks, label_mask, logits) and returns: loss