Cannot import name 'TranslationDataset' from 'torchtext.datasets'

When I import TranslationDataset form torchtext.data, I get the following error:
ImportError: cannot import name ‘TranslationDataset’ from ‘torchtext.datasets’
I have installed pytorch correctly and can import torchtext.data and torchtext.datasets, but why can’t I import TranslationDataset.
My pytorch version is 1.9.0+cu11

TranslationDataset was moved in this PR to the legacy namespace as seen here and which is also why you cannot find it in the current docs anymore, so you might be able to import it via torchtext.legacy.datasets.

1 Like