    def reorder_encoder_out(
        self, encoder_out: Dict[str, List[Tensor]], new_order: Tensor
    ):
        """
        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*
        """
        if len(encoder_out["encoder_out"]) == 0:
            encoder = []
        else:
            encoder = [encoder_out["encoder_out"][0].index_select(1, new_order)]
        output_dict = {"encoder_out": encoder}

        if ("encoder_padding_mask" not in encoder_out) or (
            len(encoder_out["encoder_padding_mask"]) == 0
        ):
            encoder_padding_mask = []
        else:
            encoder_padding_mask = [
                encoder_out["encoder_padding_mask"][0].index_select(0, new_order)
            ]
        output_dict["encoder_padding_mask"] = encoder_padding_mask
        return output_dict
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*
fairseq/models/lightconv.py