    def build_model(cls, args, task):
        """Build a new model instance."""

        # make sure all arguments are present in older models
        xm_t_base_architecture(args)

        encoder = cls.build_encoder(args)
        decoder, proj, unit_args = cls.build_decoder(
            args,
            task,
            aug_attn=getattr(args, "synthesizer_augmented_cross_attention", False),
        )
        base_model = cls(encoder, decoder)
        setattr(base_model, "proj", proj)

        base_model.t2u_augmented_cross_attn = getattr(
            args, "synthesizer_augmented_cross_attention", False
        )

        # set up multitask decoders
        base_model.mt_task_name = None
        base_model.multitask_decoders = {}
        has_first_pass_decoder = False
        for task_name, task_obj in task.multitask_tasks.items():
            if task_obj.is_first_pass_decoder:
                has_first_pass_decoder = True
                base_model.mt_task_name = task_name

            task_decoder = cls.build_multitask_decoder(
                args,
                task_obj.args,
                task_obj.target_dictionary,
                args.decoder_embed_dim,
                task_obj.is_first_pass_decoder,
            )

            setattr(base_model, f"{task_name}_decoder", task_decoder)
            decoder_model_cls = (
                FairseqEncoderModel
                if task_obj.args.decoder_type == "ctc"
                else FairseqLanguageModel
            )
            base_model.multitask_decoders[task_name] = decoder_model_cls(
                getattr(base_model, f"{task_name}_decoder")
            )

        assert has_first_pass_decoder, "set at least one intermediate non-CTC decoder"

        # set up encoder on top of the auxiliary MT decoder
        if getattr(args, "synthesizer_encoder_layers", 0) > 0:
            base_model.synthesizer_encoder = cls.build_t2u_encoder(unit_args)
        else:
            base_model.synthesizer_encoder = None

        return base_model
Build a new model instance.
fairseq/models/speech_to_text/xm_transformer_unity.py