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: Act on a batch of observations.
  
  :param observations:
      list of observations
  
  :return:
      A list of acts, one for each observation
docstr_tok: ["Act","on","a","batch","of","observations",".",":","param","observations",":","list","of","observations",":","return",":","A","list","of","acts",",","one","for","each","observation"]
code: def batch_act(self, observations):
      """
      Act on a batch of observations.
  
      :param observations:
          list of observations
  
      :return:
          A list of acts, one for each observation
      """
      is_training = any(["labels" in obs for obs in observations])
      valid_obs, valid_indexes = self.filter_valid_obs(
          observations, is_training
      )
      image_feats = self.extract_image_feats(valid_obs)
      personalities = [v.get("text", "") for v in valid_obs]
  
      chosen_captions = None
      med_rank = None
      if is_training:
          loss, num_correct, num_examples = self.train_step(
              valid_obs, image_feats, personalities
          )
      else:
          (
              loss,
              num_correct,
              num_examples,
              med_rank,
              chosen_captions,
          ) = self.eval_step(valid_obs, image_feats, personalities)
  
      self.update_metrics(loss, num_correct, num_examples, med_rank)
      result = [
          {"text": "No Response During Training"}
          for _ in range(len(observations))
      ]
      if chosen_captions is not None:
          for i, index_obs in enumerate(valid_indexes):
              result[index_obs]["text"] = chosen_captions[i][0]
              result[index_obs]["text_candidates"] = chosen_captions[i]
      return result
  
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 12 for calling the TransresnetAgent obj's underlying member method code with example usage: obj.batch_act(observations) and returns: result