    def __init__(
        self,
        models,
        tgt_dicts,
        beam_size=1,
        max_len_a=0,
        max_len_b=200,
        min_len=1,
        normalize_scores=True,
        len_penalty=1.0,
        unk_penalty=0.0,
        temperature=1.0,
        match_source_len=False,
        no_repeat_ngram_size=0,
        search_strategy=None,
        eos=None,
        symbols_to_strip_from_output=None,
        lm_model=None,
        lm_weight=1.0,
        duration_temperature=1.0,
    ):
        """Generate multi-channel parallel units with the SpeechDLM model
        as described in the paper: https://arxiv.org/pdf/2203.16502.pdf;

        Args:
            models (List[~fairseq.models.FairseqModel]): ensemble of models,
                currently support fairseq.models.TransformerModel for scripting
            beam_size (int, optional): beam width (default: 1)
            max_len_a/b (int, optional): generate sequences of maximum length
                ax + b, where x is the source length
            min_len (int, optional): the minimum length of the generated output
                (not including end-of-sentence)
            normalize_scores (bool, optional): normalize scores by the length
                of the output (default: True)
            len_penalty (float, optional): length penalty, where <1.0 favors
                shorter, >1.0 favors longer sentences (default: 1.0)
            unk_penalty (float, optional): unknown word penalty, where <0
                produces more unks, >0 produces fewer (default: 0.0)
            temperature (float, optional): temperature, where values
                >1.0 produce more uniform samples and values <1.0 produce
                sharper samples (default: 1.0)
            match_source_len (bool, optional): outputs should match the source
                length (default: False)
            duration_temperature (float, optional): rate of the duration prediction,
                higher rate induces a faster generated wav (default: 1.0)
        """
        super().__init__()
        if isinstance(models, MultichannelEnsembleModel):
            self.model = models
        else:
            self.model = MultichannelEnsembleModel(models)
        self.tgt_dicts = tgt_dicts
        self.pad = list(tgt_dicts.values())[0].pad()
        self.unk = list(tgt_dicts.values())[0].unk()
        self.eos = list(tgt_dicts.values())[0].eos() if eos is None else eos
        self.symbols_to_strip_from_output = (
            symbols_to_strip_from_output.union({self.eos})
            if symbols_to_strip_from_output is not None
            else {self.eos}
        )
        self.channels = list(tgt_dicts.keys())
        self.n_channels = len(self.channels)
        self.vocab_sizes = [len(tgt_dicts[channel]) for channel in self.channels]
        # the max beam size is the dictionary size - 1, since we never select pad
        max_possible_beam_size = 1
        for i in self.vocab_sizes:
            max_possible_beam_size *= i - 1
        self.beam_size = min(beam_size, max_possible_beam_size)
        self.max_len_a = max_len_a
        self.max_len_b = max_len_b
        self.min_len = min_len

        self.normalize_scores = normalize_scores
        self.len_penalty = len_penalty
        self.unk_penalty = unk_penalty
        if isinstance(temperature, (int, float)):
            temperature = {channel: temperature for channel in self.channels}
        elif isinstance(temperature, ListConfig) or isinstance(temperature, list):
            temperature = {
                channel: temperature[i] for i, channel in enumerate(self.channels)
            }
        assert isinstance(temperature, DictConfig) or isinstance(
            temperature, dict
        ), f"temperature: expected dict, but found {type(temperature)}"
        self.temperature = temperature
        self.match_source_len = match_source_len

        if no_repeat_ngram_size > 0:
            self.repeat_ngram_blocker = NGramRepeatBlock(no_repeat_ngram_size)
        else:
            self.repeat_ngram_blocker = None

        for channel in temperature:
            assert temperature[channel] > 0, "--temperature must be greater than 0"

        if search_strategy is None:
            self.search = ContiguousMultichannelBeamSearch(tgt_dicts)
        else:
            self.search = search_strategy
        # We only need to set src_lengths in LengthConstrainedBeamSearch.
        # As a module attribute, setting it would break in multithread
        # settings when the model is shared.
        self.should_set_src_lengths = (
            hasattr(self.search, "needs_src_lengths") and self.search.needs_src_lengths
        )

        self.model.eval()

        self.lm_model = lm_model
        self.lm_weight = lm_weight
        if self.lm_model is not None:
            self.lm_model.eval()

        self.duration_prediction = bool(
            str(getattr(models[0].decoder.args, "duration_prediction", "false")).lower()
            == "true"
        )
        self.delayed_duration = bool(
            str(
                getattr(models[0].decoder.args, "delayed_duration_target", "false")
            ).lower()
            == "true"
        )
        self.duration_temperature = duration_temperature
Generate multi-channel parallel units with the SpeechDLM model
as described in the paper: https://arxiv.org/pdf/2203.16502.pdf;

Args:
models (List[~fairseq.models.FairseqModel]): ensemble of models,
currently support fairseq.models.TransformerModel for scripting
beam_size (int, optional): beam width (default: 1)
max_len_a/b (int, optional): generate sequences of maximum length
ax + b, where x is the source length
min_len (int, optional): the minimum length of the generated output
(not including end-of-sentence)
normalize_scores (bool, optional): normalize scores by the length
of the output (default: True)
len_penalty (float, optional): length penalty, where <1.0 favors
shorter, >1.0 favors longer sentences (default: 1.0)
unk_penalty (float, optional): unknown word penalty, where <0
produces more unks, >0 produces fewer (default: 0.0)
temperature (float, optional): temperature, where values
>1.0 produce more uniform samples and values <1.0 produce
sharper samples (default: 1.0)
match_source_len (bool, optional): outputs should match the source
length (default: False)
duration_temperature (float, optional): rate of the duration prediction,
higher rate induces a faster generated wav (default: 1.0)
fairseq/models/speech_dlm/sequence_generator/multichannel_sequence_generator.py