Cannot import name 'functional_datapipe' from 'torch.utils.data'

5.2k Views Asked by At

When I am running datasets_utils.py from '/usr/local/lib/python3.7/dist-packages/torchtext/data/datasets_utils.py' in Google Colab, the following error occurs even with the most updated versions of Python packages:

ImportError: cannot import name 'functional_datapipe' from 'torch.utils.data' (/usr/local/lib/python3.7/dist-packages/torch/utils/data/init.py)

Are there any solutions to solve such errors, as I could not find functional_datapipe even in the official torch.utils.data documentation? The following is excerpt from datasets._utils.py in the Google Colab environment

import functools
import inspect
import os
import io
import torch
from torchtext.utils import (
    validate_file,
    download_from_url,
    extract_archive,
)
from torch.utils.data import functional_datapipe, IterDataPipe
from torch.utils.data.datapipes.utils.common import StreamWrapper
import codecs
1

There are 1 best solutions below

3
On

It might be available only on torchdata.datapipes