docstr: Reorder encoder output according to *new_order*.
  
  Args:
      encoder_out: output from the ``forward()`` method
      new_order (LongTensor): desired order
  
  Returns:
      *encoder_out* rearranged according to *new_order*
docstr_tok: ["Reorder","encoder","output","according","to","*","new_order","*",".","Args",":","encoder_out",":","output","from","the","``","forward","(",")","``","method","new_order","(","LongTensor",")",":","desired","order","Returns",":","*","encoder_out","*","rearranged","according","to","*","new_order","*"]
code: def reorder_encoder_out(self, encoder_out: EncoderOut, new_order):
      """
      Reorder encoder output according to *new_order*.
  
      Args:
          encoder_out: output from the ``forward()`` method
          new_order (LongTensor): desired order
  
      Returns:
          *encoder_out* rearranged according to *new_order*
      """
      """
          Since encoder_padding_mask and encoder_embedding are both of type
          Optional[Tensor] in EncoderOut, they need to be copied as local
          variables for Torchscript Optional refinement
          """
  
      if self.beam_size < 0:
          self.beam_size = int(new_order.shape[0] / self.batch_size)
      else:
          new_order = new_order // self.beam_size
      new_order = new_order[:: self.beam_size]
      new_encoder_out = encoder_out.encoder_out.index_select(
          1, new_order
      )
      new_encoder_padding_mask = (
          encoder_out.encoder_padding_mask.index_select(0, new_order)
      )
  
      return EncoderOut(
          encoder_out=new_encoder_out,  # T x B x C
          encoder_padding_mask=new_encoder_padding_mask,  # B x T
          encoder_embedding=None,  # B x T x C
          encoder_states=None,
          src_tokens=None,
          src_lengths=None,
      )
  
imports: import torch
  import torch.nn
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.models.fairseq_encoder import EncoderOut
  from fairseq.modules import LayerNorm
  from lightseq.training.ops.pytorch.layer_base import TransformerEmbeddingLayerBase
  from lightseq.training.ops.pytorch.quantization import QuantLinear, disable_quant, enable_quant, ptq_mode, qat_mode
label_desc: Use image node_id 6 for calling the LSTransformerEncoder obj's underlying member method code with example usage: obj.reorder_encoder_out(encoder_out, new_order) and returns: EncoderOut