    def get_emissions(self, models, encoder_input):
        """Run encoder and normalize emissions"""
        model = models[0]

        all_encoder_out = [m(**encoder_input) for m in models]

        if len(all_encoder_out) > 1:

            if "encoder_out" in all_encoder_out[0]:
                encoder_out = {
                    "encoder_out": sum(e["encoder_out"] for e in all_encoder_out)
                    / len(all_encoder_out),
                    "encoder_padding_mask": all_encoder_out[0]["encoder_padding_mask"],
                }
                padding = encoder_out["encoder_padding_mask"]
            else:
                encoder_out = {
                    "logits": sum(e["logits"] for e in all_encoder_out)
                    / len(all_encoder_out),
                    "padding_mask": all_encoder_out[0]["padding_mask"],
                }
                padding = encoder_out["padding_mask"]
        else:
            encoder_out = all_encoder_out[0]
            padding = (
                encoder_out["padding_mask"]
                if "padding_mask" in encoder_out
                else encoder_out["encoder_padding_mask"]
            )

        if hasattr(model, "get_logits"):
            emissions = model.get_logits(encoder_out, normalize=True)
        else:
            emissions = model.get_normalized_probs(encoder_out, log_probs=True)

        return (
            emissions.cpu().float().transpose(0, 1),
            padding.cpu() if padding is not None and padding.any() else None,
        )
Run encoder and normalize emissions
examples/speech_recognition/kaldi/kaldi_decoder.py