Error with _DataLoaderIter in torch.utils.data.dataloader
I want to run a code which needs to import _DataLoaderIter from torch.utils.data.dataloader. By checking the source code for dataloader class, that method exist. However, I get the error:


  Traceback (most recent call last):
  
  File "main.py", line 4, in 
  
  import data
  
  File "D:\Hyperspectral Data\RCAN\RCAN_TrainCode\code\data\__init__.py", line 3, in module
  
  from dataloader import MSDataLoader
  
  File "D:\Hyperspectral Data\RCAN\RCAN_TrainCode\code\dataloader.py", line 14, in module
  
  from torch.utils.data.dataloader import _DataLoaderIter
  
  ImportError: cannot import name '_DataLoaderIter'


Why is this happening?

Your comment answers the question: the _DataLoaderIter is there in 1.0.0 (for which you are linking documentation) but not in 0.3.1, as you can check here - its name has no preceding _.

This is a textbook example why it is a bad idea to access other packages' private classes/functions (customarily prefixed with an underscore) - you have zero guarantees on the stability of their implementation and behavior. If you need their code, it's usually better to copy-paste the code to your own file, because there it is at least guaranteed to not change between updates and bug fixes to torch.
