class_docstr: Model described in (https://arxiv.org/abs/1811.00945).
  
  A model for producing engaging captions about an image. Given an image and
  this model will attempt to predict an appropriate
  next utterance in the dialog, in the context of a given personality.
  
  See the paper linked above for more information.
class_docstr_tok: ["Model","described","in","(","https",":","\/\/arxiv.org\/abs\/1811.00945",")",".","A","model","for","producing","engaging","captions","about","an","image",".","Given","an","image","and","this","model","will","attempt","to","predict","an","appropriate","next","utterance","in","the","dialog",",","in","the","context","of","a","given","personality",".","See","the","paper","linked","above","for","more","information","."]
docstr: Update Metrics.
  
  :param loss:
      float loss
  :param num_correct:
      number of examples for which chosen caption is correct
  :param num_samples:
      total number of examples
  :param med_rank:
      rank of correct caption for each example
docstr_tok: ["Update","Metrics",".",":","param","loss",":","float","loss",":","param","num_correct",":","number","of","examples","for","which","chosen","caption","is","correct",":","param","num_samples",":","total","number","of","examples",":","param","med_rank",":","rank","of","correct","caption","for","each","example"]
code: def update_metrics(
      self, loss, num_correct, num_samples, med_rank=None
  ):
      """
      Update Metrics.
  
      :param loss:
          float loss
      :param num_correct:
          number of examples for which chosen caption is correct
      :param num_samples:
          total number of examples
      :param med_rank:
          rank of correct caption for each example
      """
      self.metrics["hits@1/100"] += num_correct
      self.metrics["loss"] += loss
      self.metrics["num_samples"] += num_samples
      if med_rank:
          self.metrics["med_rank"] += med_rank
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.agents import Agent
  from parlai.core.dict import DictionaryAgent
  from parlai.utils.misc import round_sigfigs
  from .modules import TransresnetModel
  from parlai.tasks.personality_captions.build import build
  from parlai.utils.io import PathManager
  import parlai.utils.torch
  import os
  import random
  import json
  import numpy
  import torch
  import tqdm
label_desc: Use image node_id 15 for calling the TransresnetAgent obj's underlying member method code with example usage: obj.update_metrics(loss, num_correct, num_samples, med_rank) without return types