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: Receive the metrics from validation.
  
  Unfreeze text encoder weights after a certain number of rounds without improvement.
  
  :param metrics_dict:
      the metrics dictionary
docstr_tok: ["Receive","the","metrics","from","validation",".","Unfreeze","text","encoder","weights","after","a","certain","number","of","rounds","without","improvement",".",":","param","metrics_dict",":","the","metrics","dictionary"]
code: def receive_metrics(self, metrics_dict):
      """
      Receive the metrics from validation.
  
      Unfreeze text encoder weights after a certain number of rounds without improvement.
  
      :param metrics_dict:
          the metrics dictionary
      """
      if "tasks" in metrics_dict:
          metrics_dict = metrics_dict["tasks"]["personality_captions"]
      if self.freeze_patience != -1 and self.is_frozen:
          m = metrics_dict["hits@1/100"]
          if m > self.freeze_best_metric:
              self.freeze_impatience = 0
              self.freeze_best_metric = m
              print(
                  "performance not good enough to unfreeze the model."
              )
          else:
              self.freeze_impatience += 1
              print("Growing impatience for unfreezing")
              if self.freeze_impatience >= self.freeze_patience:
                  self.is_frozen = False
                  print(
                      "Reached impatience for fine tuning. "
                      "Reloading the best model so far."
                  )
                  self._build_model(self.model_file)
                  if self.use_cuda:
                      self.model = self.model.cuda()
                  print("Unfreezing.")
                  self.model.unfreeze_text_encoder()
                  print("Done")
  
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 17 for calling the TransresnetAgent obj's underlying member method code with example usage: obj.receive_metrics(metrics_dict) without return types