    def reorder_incremental_state_scripting(
        self,
        incremental_state: List[Dict[str, Dict[str, Optional[Tensor]]]],
        new_order: Tensor,
    ):
        """Main entry point for reordering the incremental state.

        Due to limitations in TorchScript, we call this function in
        :class:`fairseq.sequence_generator.SequenceGenerator` instead of
        calling :func:`reorder_incremental_state` directly.
        """
        for module in self.modules():
            if hasattr(module, "reorder_incremental_state"):
                for i, incremental_state_channel in enumerate(incremental_state):
                    result = module.reorder_incremental_state(
                        incremental_state_channel, new_order
                    )
                    if result is not None:
                        incremental_state[i] = result
Main entry point for reordering the incremental state.

Due to limitations in TorchScript, we call this function in
:class:`fairseq.sequence_generator.SequenceGenerator` instead of
calling :func:`reorder_incremental_state` directly.
fairseq/models/speech_dlm/modules/speech_dlm_decoder.py