align/models.py [333:353]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                 tokenizer='facebook/mbart-large-cc25', device='cpu'):
        from fairseq import bleu, checkpoint_utils, options, progress_bar, tasks, utils
        from fairseq.sequence_generator import EnsembleModel
        self.device = device
        args = torch.load(args_path)
        task = tasks.setup_task(args)
        models, _model_args = checkpoint_utils.load_model_ensemble(
            path.split(':'),
            arg_overrides=eval('{}'),
            task=task
        )
        for model in models:
            model.make_generation_fast_(
                beamable_mm_beam_size=None if args.no_beamable_mm else args.beam,
                need_attn=args.print_alignment,
            )
            if args.fp16:
                model.half()
            model = model.to(self.device)
        self.model = EnsembleModel(models).to(self.device)
        self.tokenizer = AutoTokenizer.from_pretrained(tokenizer)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/models.py [12:32]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                 tokenizer='facebook/mbart-large-cc25', device='cpu'):
        from fairseq import bleu, checkpoint_utils, options, progress_bar, tasks, utils
        from fairseq.sequence_generator import EnsembleModel
        self.device = device
        args = torch.load(args_path)
        task = tasks.setup_task(args)
        models, _model_args = checkpoint_utils.load_model_ensemble(
            path.split(':'),
            arg_overrides=eval('{}'),
            task=task
        )
        for model in models:
            model.make_generation_fast_(
                beamable_mm_beam_size=None if args.no_beamable_mm else args.beam,
                need_attn=args.print_alignment,
            )
            if args.fp16:
                model.half()
            model = model.to(self.device)
        self.model = EnsembleModel(models).to(self.device)
        self.tokenizer = AutoTokenizer.from_pretrained(tokenizer)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



