code: def _decode(
      self,
      tokens,
      encoder_outs,
      incremental_states,
      possible_translation_tokens=None,
  ):
      avg_attn = None
      all_translation_tokens = []
      all_log_probs = []
      for model_weight, model, encoder_out in zip(
          self.model_weights, self.models, encoder_outs
      ):
          with torch.no_grad():
              if (
                  possible_translation_tokens is not None
                  and len(possible_translation_tokens.shape) > 1
              ):
                  # reverse beam replication
                  possible_translation_tokens = (
                      possible_translation_tokens[0]
                  )
  
              decoder_out = list(
                  model.decoder(
                      tokens,
                      encoder_out,
                      incremental_states[model],
                      possible_translation_tokens=possible_translation_tokens,
                  )
              )
              decoder_out[0] = decoder_out[0][:, -1, :]
              if self.temperature != 1.0:
                  decoder_out[0].div_(self.temperature)
              attn = decoder_out[1]
              if len(decoder_out) == 3:
                  possible_translation_tokens = decoder_out[2]
              else:
                  possible_translation_tokens = None
              if (
                  hasattr(model.decoder, "adaptive_softmax")
                  and model.decoder.adaptive_softmax is not None
              ):
                  decoder_out[0] = decoder_out[0].unsqueeze(1)
                  # to use get_normalized_probs in adaptive softmax decoder
                  # the sample object is needed. During inference, the target
                  # should be set to None
                  log_probs = model.get_normalized_probs(
                      decoder_out,
                      log_probs=True,
                      sample={"target": None},
                  )
                  log_probs = model_weight * log_probs[:, -1, :]
              else:
                  log_probs = model.get_normalized_probs(
                      decoder_out, log_probs=True
                  )
                  log_probs = model_weight * log_probs
              all_translation_tokens.append(possible_translation_tokens)
              all_log_probs.append(log_probs)
  
          if attn is not None:
              attn = attn[:, -1, :].data
              if avg_attn is None:
                  avg_attn = attn
              else:
                  avg_attn.add_(attn)
  
      (
          avg_log_probs,
          possible_translation_tokens,
      ) = SequenceGenerator.gather_probs(
          all_translation_tokens=all_translation_tokens,
          all_probs=all_log_probs,
      )
      if avg_attn is not None:
          avg_attn.div_(len(self.models))
  
      return avg_log_probs, avg_attn, possible_translation_tokens
  
imports: import math
  from typing import List, Tuple
  import torch
  from fairseq import search, utils
  from fairseq.models import FairseqIncrementalDecoder
  from pytorch_translate import utils
  from torch import Tensor
label_desc: Use image node_id 15 for calling the SequenceGenerator obj's underlying member method code with example usage: obj._decode(tokens, encoder_outs, incremental_states, possible_translation_tokens) and returns: avg_log_probs,  avg_attn,  possible_translation_tokens