code: def _encode(self, encoder_inputs, beam_size, srcs_ids):
      encoder_outs = [[] for _ in range(len(srcs_ids))]
  
      def pick_src_encodings(encoder_out, src_ids):
          (
              unpacked_output,
              final_hiddens,
              final_cells,
              src_lengths,
              src_tokens,
          ) = encoder_out
          unpacked_output = unpacked_output.index_select(1, src_ids)
          final_hiddens = final_hiddens.index_select(1, src_ids)
          final_cells = final_cells.index_select(1, src_ids)
          src_lengths = src_lengths.index_select(0, src_ids)
          src_tokens = src_tokens.index_select(0, src_ids)
          max_src_len = src_lengths.data.max()
          return (
              unpacked_output[:max_src_len, :, :],
              final_hiddens,
              final_cells,
              src_lengths,
              src_tokens[:, :max_src_len],
          )
  
      # Enumerate all input/model pair
      # At this point encoder_input is a tuple of srcs_tokens and srcs_lengths
      # So we call zip(*) on it to get a list of token, length tuples
      for model in self.models:
          if not self.retain_dropout:
              model.eval()
          encoder_out = model.encoder(*encoder_inputs)
          for k, src_ids in enumerate(srcs_ids):
              # Get the encodings corresponding to each source sentence
              encoder_out_k = pick_src_encodings(encoder_out, src_ids)
              # expand outputs for each example beam_size times
              encoder_out_k = model.expand_encoder_output(
                  encoder_out_k, beam_size
              )
              encoder_outs[k].append(encoder_out_k)
      return encoder_outs
  
file_path: translate/pytorch_translate/research/multisource/multisource_decode.py
imports: import math
  import torch
  from fairseq import utils
  from fairseq.models import FairseqIncrementalDecoder
label_desc: Use image node_id 7 for calling the MultiSourceSequenceGenerator obj's underlying member method code with example usage: obj._encode(encoder_inputs, beam_size, srcs_ids) and returns: encoder_outs, unpacked_output,  final_hiddens,  final_cells,  src_lengths,  src_tokens