class_docstr: Transformer encoder.
class_docstr_tok: ["Transformer","encoder","."]
code: def reorder_encoder_out(self, encoder_out, new_order):
      (x, src_tokens, encoder_padding_mask) = encoder_out
      src_tokens_tensor = (
          pytorch_translate_utils.get_source_tokens_tensor(src_tokens)
      )
      if x is not None:
          x = x.index_select(1, new_order)
      if src_tokens_tensor is not None:
          src_tokens_tensor = src_tokens_tensor.index_select(
              0, new_order
          )
      if encoder_padding_mask.shape == torch.Size([]):
          encoder_padding_mask = None
      if encoder_padding_mask is not None:
          encoder_padding_mask = encoder_padding_mask.index_select(
              0, new_order
          )
      return (x, src_tokens_tensor, encoder_padding_mask)
  
imports: import math
  import random
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import options, utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture, transformer
  from fairseq.modules import AdaptiveSoftmax, LayerNorm, MultiheadAttention, SinusoidalPositionalEmbedding
  from pytorch_translate import utils, vocab_reduction
  from pytorch_translate.average_attention import AverageAttention
  from pytorch_translate.common_layers import TransformerEmbedding, TransformerEncoderGivenEmbeddings, TransformerTokenEmbedding, VariableTracker
  from pytorch_translate.semi_supervised import SemiSupervisedModel
  from pytorch_translate.utils import torch_find
label_desc: Use image node_id 3 for calling the TransformerEncoder obj's underlying member method code with example usage: obj.reorder_encoder_out(encoder_out, new_order) and returns: x,  src_tokens_tensor,  encoder_padding_mask