class_docstr: Recurrent decoder module that uses dialog history encoded by context lstm.
class_docstr_tok: ["Recurrent","decoder","module","that","uses","dialog","history","encoded","by","context","lstm","."]
docstr: Decode from input tokens.
  
  :param xs: (bsz x seqlen) LongTensor of input token indices
  :param encoder_output: output from HredEncoder. Tuple containing
      (enc_out, enc_hidden, attn_mask, context_hidden) tuple.
  :param incremental_state: most recent hidden state to the decoder.
  :returns: (output, hidden_state) pair from the RNN.
      - output is a bsz x time x latentdim matrix. This value must be passed to
          the model's OutputLayer for a final softmax.
      - hidden_state depends on the choice of RNN
docstr_tok: ["Decode","from","input","tokens",".",":","param","xs",":","(","bsz","x","seqlen",")","LongTensor","of","input","token","indices",":","param","encoder_output",":","output","from","HredEncoder",".","Tuple","containing","(","enc_out",",","enc_hidden",",","attn_mask",",","context_hidden",")","tuple",".",":","param","incremental_state",":","most","recent","hidden","state","to","the","decoder",".",":","returns",":","(","output",",","hidden_state",")","pair","from","the","RNN",".","-","output","is","a","bsz","x","time","x","latentdim","matrix",".","This","value","must","be","passed","to","the","model","'s","OutputLayer","for","a","final","softmax",".","-","hidden_state","depends","on","the","choice","of","RNN"]
code: def forward(self, xs, encoder_output, incremental_state=None):
      """
      Decode from input tokens.
  
      :param xs: (bsz x seqlen) LongTensor of input token indices
      :param encoder_output: output from HredEncoder. Tuple containing
          (enc_out, enc_hidden, attn_mask, context_hidden) tuple.
      :param incremental_state: most recent hidden state to the decoder.
      :returns: (output, hidden_state) pair from the RNN.
          - output is a bsz x time x latentdim matrix. This value must be passed to
              the model's OutputLayer for a final softmax.
          - hidden_state depends on the choice of RNN
      """
      (
          enc_state,
          (hidden_state, cell_state),
          attn_mask,
          context_hidden,
      ) = encoder_output
  
      # sequence indices => sequence embeddings
      seqlen = xs.size(1)
      xes = self.dropout(self.lt(xs))
  
      # concatenate context lstm hidden state
      context_hidden_final_layer = context_hidden[:, -1, :].unsqueeze(1)
      resized_context_h = context_hidden_final_layer.expand(
          -1, seqlen, -1
      )
      xes = torch.cat((xes, resized_context_h), dim=-1).to(xes.device)
  
      # run through rnn with None as initial decoder state
      # source for zeroes hidden state: http://www.cs.toronto.edu/~lcharlin/papers/vhred_aaai17.pdf
      output, new_hidden = self.rnn(xes, None)
  
      return output, _transpose_hidden_state(new_hidden)
  
file_path: ParlAI/parlai/agents/hred/modules.py
imports: import torch
  import torch.nn
  from parlai.agents.seq2seq.modules import OutputLayer, RNNEncoder, _transpose_hidden_state
  from parlai.core.torch_generator_agent import TorchGeneratorModel
label_desc: Use image node_id 2 for calling the HredDecoder obj's underlying member method code with example usage: obj.forward(xs, encoder_output, incremental_state) and returns: output,  _transpose_hidden_state