Repository: pytorch
Issue: None returned from data loader causes debugging difficulty from collate function
Labels: module: dataloader,triaged

### 🐛 Describe the bug

None returned from data loader causes debugging difficulty from collate function as a len() check is used in default_collate.
Adding a None check would help trace the problem back to dataloader easier. (Newbie here! so sorry if i'm missing something, but I think it could save sometime to some one! :D)

`if any(elem is None for elem in it):
            raise RuntimeError('you messed something on your get item process mate')`

```
def default_collate(batch):
    r"""Puts each data field into a tensor with outer dimension batch size"""
....
  elif isinstance(elem, collections.abc.Sequence):
          # check to make sure that the elements in batch have consistent size
          it = iter(batch)
#health check before len(elem) call
          if any(elem is None for elem in it):
               raise RuntimeError('you messed something on your get item process mate')
          elem_size = len(next(it)) 
          if not all(len(elem) == elem_size for elem in it):
              raise RuntimeError('each element in list of batch should be of equal size')
          transposed = zip(*batch)
          return [default_collate(samples) for samples in transposed]
```
Original Traceback (most recent call last):
  File "/home/sc/anaconda3/envs/PythonDev3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/sc/anaconda3/envs/PythonDev3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
    return self.collate_fn(data)
  File "/home/sc/anaconda3/envs/PythonDev3/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 81, in default_collate
    if not all(len(elem) == elem_size for elem in it):
  File "/home/sc/anaconda3/envs/PythonDev3/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 81, in <genexpr>
    if not all(len(elem) == elem_size for elem in it):
TypeError: object of type 'NoneType' has no len()


### Versions

PyTorch version: 1.10.0
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.17

Python version: 3.7.11 (default, Jul 27 2021, 14:32:16)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.13.0-35-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2080 SUPER
Nvidia driver version: 495.29.05
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.2
[pip3] torch==1.10.0
[pip3] torch-tb-profiler==0.3.1
[pip3] torchaudio==0.10.0
[pip3] torchvision==0.11.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               10.2.89              hfd86e86_1  
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.3.0           h06a4308_520  
[conda] mkl-service               2.4.0            py37h7f8727e_0  
[conda] mkl_fft                   1.3.1            py37hd3c417c_0  
[conda] mkl_random                1.2.2            py37h51133e4_0  
[conda] numpy                     1.21.2           py37h20f2e39_0  
[conda] numpy-base                1.21.2           py37h79a1101_0  
[conda] pytorch                   1.10.0          py3.7_cuda10.2_cudnn7.6.5_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch-tb-profiler         0.3.1                    pypi_0    pypi
[conda] torchaudio                0.10.0               py37_cu102    pytorch
[conda] torchvision               0.11.1               py37_cu102    pytorch

cc @SsnL @VitalyFedyunin @ejguan @NivekT