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: Override TGM.decode_forced to return latent states and using generator_output
  method to generate the decoder output.
docstr_tok: ["Override","TGM.decode_forced","to","return","latent","states","and","using","generator_output","method","to","generate","the","decoder","output","."]
code: def decode_forced(
      self, encoder_states: Tuple[Any], ys: torch.LongTensor
  ) -> Tuple[
      torch.Tensor, torch.LongTensor, torch.Tensor, torch.BoolTensor
  ]:
      """
      Override TGM.decode_forced to return latent states and using generator_output
      method to generate the decoder output.
      """
      bsz = ys.size(0)
      seqlen = ys.size(1)
      inputs = ys.narrow(1, 0, seqlen - 1)
      if (ys[:, 0] == self.START_IDX).any():
          raise AssertionError(
              "The Beginning of Sentence token is automatically added to the "
              "label in decode_forced, but you included it in the label. This means "
              "your model will have a double BOS token, which is probably not what "
              "you intended."
          )
      inputs = self._get_initial_forced_decoder_input(bsz, inputs)
      latent, mask = self.decoder(inputs, encoder_states)
      logits = self.generator_output(latent)
      _, preds = logits.max(dim=2)
      return logits, preds, latent, mask
  
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 7 for calling the DirectorModel obj's underlying member method code with example usage: obj.decode_forced(encoder_states, ys) and returns: logits,  preds,  latent,  mask