class_docstr: Rescores source and target tokens based on a model
docstr: Run model decoder on tgt_tokens and encoder_outputs
  
  Args:
    args: model arguments
    model: given rescoring model
    encoder_outs: encoder output. list(tuple([[input_length, batch_size,
      hidden_dim], [batch_size, input_length]))
    tgt_tokens: target tokens to be rescored. target tokens are expected
      to start with eos to signal start of the sentence, and expected to
      to end with eos to score eos. therefore target_size should be equal
      to number_of_target_tokens + 2, and should return
      number_of_target_tokens + 1 output. [batch_size, target_length]
  
  Returns:
    logprobs: log probabilities for each tgt token [batch_size,
      target_length, vocab_size]
  
  Raises:
    ValueError: If there is a problem with input.
    * If tgt_tokens don't start and end with eos.
docstr_tok: ["Run","model","decoder","on","tgt_tokens","and","encoder_outputs","Args",":","args",":","model","arguments","model",":","given","rescoring","model","encoder_outs",":","encoder","output",".","list","(","tuple","(","[","[","input_length",",","batch_size",",","hidden_dim","]",",","[","batch_size",",","input_length","]",")",")","tgt_tokens",":","target","tokens","to","be","rescored",".","target","tokens","are","expected","to","start","with","eos","to","signal","start","of","the","sentence",",","and","expected","to","to","end","with","eos","to","score","eos",".","therefore","target_size","should","be","equal","to","number_of_target_tokens","+","2",",","and","should","return","number_of_target_tokens","+","1","output",".","[","batch_size",",","target_length","]","Returns",":","logprobs",":","log","probabilities","for","each","tgt","token","[","batch_size",",","target_length",",","vocab_size","]","Raises",":","ValueError",":","If","there","is","a","problem","with","input",".","*","If","tgt_tokens","do","n't","start","and","end","with","eos","."]
code: def decode(self, args, model, encoder_outs, tgt_tokens):
      """Run model decoder on tgt_tokens and encoder_outputs
  
      Args:
        args: model arguments
        model: given rescoring model
        encoder_outs: encoder output. list(tuple([[input_length, batch_size,
          hidden_dim], [batch_size, input_length]))
        tgt_tokens: target tokens to be rescored. target tokens are expected
          to start with eos to signal start of the sentence, and expected to
          to end with eos to score eos. therefore target_size should be equal
          to number_of_target_tokens + 2, and should return
          number_of_target_tokens + 1 output. [batch_size, target_length]
  
      Returns:
        logprobs: log probabilities for each tgt token [batch_size,
          target_length, vocab_size]
  
      Raises:
        ValueError: If there is a problem with input.
        * If tgt_tokens don't start and end with eos.
      """
      eos = self.task.target_dictionary.eos()
      unk = self.task.target_dictionary.unk()
  
      if (tgt_tokens == eos).sum() != 2 * tgt_tokens.size()[0]:
          raise ValueError("Each target should have 2 eos tokens")
  
      decoder_out = list(model.decoder(tgt_tokens, encoder_outs[0]))
      possible_translation_tokens = (
          decoder_out[2] if len(decoder_out) == 3 else None
      )
  
      logprobs = model.get_normalized_probs(decoder_out, log_probs=True)
  
      if possible_translation_tokens is not None:
          unk_pos = torch.nonzero(possible_translation_tokens == unk)
          if unk_pos.size()[0] != 0:
              # add unk_reward if unk appears in possible_translation_tokens
              unk_index = unk_pos[0][0]
              logprobs[:, :, unk_index] += self.args.unk_reward
  
      return logprobs, possible_translation_tokens
  
imports: import torch
  from pytorch_translate import utils
label_desc: Use image node_id 4 for calling the SimpleModelScorer obj's underlying member method code with example usage: obj.decode(args, model, encoder_outs, tgt_tokens) and returns: logprobs,  possible_translation_tokens