2021-11-30 19:32:07 +00:00
|
|
|
import operator
|
2021-03-05 20:39:52 +00:00
|
|
|
|
2021-11-30 19:32:07 +00:00
|
|
|
from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_LEGACY
|
|
|
|
|
|
|
|
if _TORCHTEXT_LEGACY:
|
|
|
|
if _compare_version("torchtext", operator.ge, "0.9.0"):
|
|
|
|
from torchtext.legacy.data import Batch, Dataset, Example, Field, Iterator, LabelField
|
|
|
|
else:
|
|
|
|
from torchtext.data import Batch, Dataset, Example, Field, Iterator, LabelField
|
2021-03-05 20:39:52 +00:00
|
|
|
else:
|
2021-11-30 19:32:07 +00:00
|
|
|
Batch = type(None)
|
|
|
|
Dataset = type(None)
|
|
|
|
Example = type(None)
|
|
|
|
Field = type(None)
|
|
|
|
Iterator = type(None)
|
|
|
|
LabelField = type(None)
|