code: def decode(self, numberized_input, max_output_seq_len):
      workspace.FeedBlob(
          self.encoder_inputs,
          np.array(
              [[token_id] for token_id in reversed(numberized_input)]
          ).astype(dtype=np.int32),
      )
      workspace.FeedBlob(
          self.encoder_lengths,
          np.array([len(numberized_input)]).astype(dtype=np.int32),
      )
      workspace.FeedBlob(
          self.max_output_seq_len,
          np.array([max_output_seq_len]).astype(dtype=np.int64),
      )
  
      workspace.RunNet(self.model.net)
  
      num_steps = max_output_seq_len
      score_beam_list = workspace.FetchBlob(self.output_score_beam_list)
      token_beam_list = workspace.FetchBlob(self.output_token_beam_list)
      prev_index_beam_list = workspace.FetchBlob(
          self.output_prev_index_beam_list
      )
  
      attention_weights_beam_list = workspace.FetchBlob(
          self.output_attention_weights_beam_list
      )
      best_indices = (num_steps, 0)
      for i in range(num_steps + 1):
          for hyp_index in range(self.beam_size):
              if (
                  token_beam_list[i][hyp_index][0]
                  == seq2seq_util.EOS_ID
                  or i == num_steps
              ) and (
                  score_beam_list[i][hyp_index][0]
                  > score_beam_list[best_indices[0]][best_indices[1]][0]
              ):
                  best_indices = (i, hyp_index)
  
      i, hyp_index = best_indices
      output = []
      attention_weights_per_token = []
      best_score = -score_beam_list[i][hyp_index][0]
      while i > 0:
          output.append(token_beam_list[i][hyp_index][0])
          attention_weights_per_token.append(
              attention_weights_beam_list[i][hyp_index]
          )
          hyp_index = prev_index_beam_list[i][hyp_index][0]
          i -= 1
  
      attention_weights_per_token = reversed(
          attention_weights_per_token
      )
      # encoder_inputs are reversed, see get_batch func
      attention_weights_per_token = [
          list(reversed(attention_weights))[: len(numberized_input)]
          for attention_weights in attention_weights_per_token
      ]
      output = list(reversed(output))
      return output, attention_weights_per_token, best_score
  
imports: from abc import ABCMeta, abstractmethod
  import argparse
  import logging
  import numpy
  import sys
  from caffe2.python import core, rnn_cell, workspace
  from caffe2.python.models.seq2seq.beam_search import BeamSearchForwardOnly
  from caffe2.python.models.seq2seq.seq2seq_model_helper import Seq2SeqModelHelper
  import caffe2.python.models.seq2seq.seq2seq_util
label_desc: Use image node_id 6 for calling the Seq2SeqModelCaffe2EnsembleDecoder obj's underlying member method code with example usage: obj.decode(numberized_input, max_output_seq_len) and returns: output,  attention_weights_per_token,  best_score