code: def reorder_encoder_output(encoder_out, new_order):
      """Reorder all outputs according to new_order."""
      (
          unpacked_output,
          final_hiddens,
          final_cells,
          src_lengths,
          src_tokens,
          src_embeddings,
      ) = encoder_out
      unpacked_output = unpacked_output.index_select(1, new_order)
      final_hiddens = final_hiddens.index_select(1, new_order)
      final_cells = final_cells.index_select(1, new_order)
      src_lengths = src_lengths.index_select(0, new_order)
      src_tokens = pytorch_translate_utils.get_source_tokens_tensor(
          src_tokens
      ).index_select(0, new_order)
      src_embeddings = src_embeddings.index_select(1, new_order)
      return (
          unpacked_output,
          final_hiddens,
          final_cells,
          src_lengths,
          src_tokens,
          src_embeddings,
      )
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.onnx.operators
  from fairseq import options, utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, register_model, register_model_architecture
  from fairseq.modules import AdaptiveSoftmax
  from pytorch_translate import attention, rnn_cell, utils, vocab_reduction
  from pytorch_translate.common_layers import ContextEmbedding, DecoderWithOutputProjection, Embedding, Linear, RNNLayer, VariableTracker
  from pytorch_translate.data import data
  from pytorch_translate.multi_model import MultiDecoder, MultiEncoder
  from pytorch_translate.multilingual import MultilingualDecoder, MultilingualEncoder
  from pytorch_translate.ngram import NGramDecoder
  from pytorch_translate.semi_supervised import SemiSupervisedModel
  from pytorch_translate.utils import maybe_cat, maybe_cuda, torch_find
  from torch.nn.utils.rnn import pack_padded_sequence, PackedSequence, pad_packed_sequence
label_desc: Use image node_id 1 for calling a global function with example usage: reorder_encoder_output(encoder_out, new_order) and returns: unpacked_output,  final_hiddens,  final_cells,  src_lengths,  src_tokens,  src_embeddings