The error occurred:‘Generator’ object has no attribute ‘translate’

I am using the mass translation model based on fairseq to apply it to the Django server.Therefore, in the translation phase, I try to use the translate method for reference: fairseq/examples/translation at main · pytorch/fairseq · GitHub

from fairseq.models.xtransformer import XTransformerModel
zh2en = XTransformerModel.from_pretrained(
data_name_or_path='/work/qymeng5/MASS_test/vocabulary', #Vocabulary path
bpe_codes='/work/qymeng5/MASS_test/bpe/' #Chinese BPE path

ff=zh2en.translate('你好 世界')

But running this code will report this error. Is it because MASS doesn’t implement the translate method, or is it my code problem?

Also tracked here.