    def get_normalized_probs_scriptable(
        self,
        net_output: Tuple[Tensor, Optional[Dict[str, List[Optional[Tensor]]]]],
        log_probs: bool,
        sample: Optional[Dict[str, Tensor]] = None,
    ):
        """Get normalized probabilities (or log probs) from a net's output."""

        logits_dict = net_output[0]
        out_dict = {}
        for channel in logits_dict:
            out_dict[channel] = {}
            for pred_channel in logits_dict[channel]:
                if isinstance(logits_dict[channel][pred_channel], dict):
                    pred_token_logits = logits_dict[channel][pred_channel]["pred_token"]
                else:
                    pred_token_logits = logits_dict[channel][pred_channel]
                if log_probs:
                    out = utils.log_softmax(
                        pred_token_logits, dim=-1, onnx_trace=self.onnx_trace
                    )
                else:
                    out = utils.softmax(
                        pred_token_logits, dim=-1, onnx_trace=self.onnx_trace
                    )
                if isinstance(logits_dict[channel][pred_channel], dict):
                    out_dict[channel][pred_channel] = {
                        "pred_token": out,
                        "pred_duration": logits_dict[channel][pred_channel][
                            "pred_duration"
                        ].float(),
                    }  # move to float32 to avoid inf loss
                else:
                    out_dict[channel][pred_channel] = out
        return out_dict
Get normalized probabilities (or log probs) from a net's output.
fairseq/models/speech_dlm/modules/speech_dlm_decoder.py