class_docstr: Director model that extends TransformerGeneratorModel and adds |V| binary classifier
  heads.
class_docstr_tok: ["Director","model","that","extends","TransformerGeneratorModel","and","adds","|V|","binary","classifier","heads","."]
docstr: Nearly copied verbatim, except for return type to return the latent state and
  the classifier scores.
docstr_tok: ["Nearly","copied","verbatim",",","except","for","return","type","to","return","the","latent","state","and","the","classifier","scores","."]
code: def forward(
      self, *xs, ys=None, prev_enc=None, maxlen=None, bsz=None
  ) -> Tuple[
      torch.Tensor,
      torch.Tensor,
      torch.LongTensor,
      torch.Tensor,
      torch.BoolTensor,
      Any,
  ]:
      """
      Nearly copied verbatim, except for return type to return the latent state and
      the classifier scores.
      """
      assert (
          ys is not None
      ), "Greedy decoding in TGModel.forward no longer supported."
      self.longest_label = max(self.longest_label, ys.size(1))
  
      # use cached encoding if available
      encoder_states = (
          prev_enc if prev_enc is not None else self.encoder(*xs)
      )
  
      # use teacher forcing
      scores, preds, latent, mask = self.decode_forced(
          encoder_states, ys
      )
  
      classifer_score = self.classifier_output(latent)
      return (
          scores,
          preds,
          classifer_score,
          latent,
          mask,
          encoder_states,
      )
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from typing import Optional, Any, Dict, Tuple, Union
  from parlai.agents.transformer.modules import TransformerGeneratorModel
  from parlai.agents.transformer.transformer import TransformerGeneratorAgent
  from parlai.core.dict import DictionaryAgent
  from parlai.core.message import Message
  from parlai.core.metrics import AverageMetric
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.torch_generator_agent import PPLMetric
  import parlai.utils.logging
label_desc: Use image node_id 6 for calling the DirectorModel obj's underlying member method code with example usage: obj.forward() and returns: scores,  preds,  classifer_score,  latent,  mask,  encoder_states