Error iterating over Dataset with DataLoader
COLLABORATOR
Instead of:
```python
dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_sampler=32)
```
It should be:
```python
dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_size=32)
```

`batch_sampler` accepts a Sampler object or an Iterable, so you get an error.
2021-01-22T02:25:46Z
https://github.com/huggingface/datasets/issues/1765#issuecomment-765069962
https://api.github.com/repos/huggingface/datasets/issues/1765
MDEyOklzc3VlQ29tbWVudDc2NTA2OTk2Mg==
https://api.github.com/repos/huggingface/datasets/issues/comments/765069962/reactions
2021-01-22T02:25:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/765069962
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
NONE
@mariosasko I thought that would fix it, but now I'm getting a different error:

```
/usr/local/lib/python3.6/dist-packages/datasets/arrow_dataset.py:851: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /pytorch/torch/csrc/utils/tensor_numpy.cpp:141.)
  return torch.tensor(x, **format_kwargs)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-20-3af1d82bf93a> in <module>()
      1 dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_size=32)
----> 2 next(iter(dataloader))

5 frames
/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/collate.py in default_collate(batch)
     53             storage = elem.storage()._new_shared(numel)
     54             out = elem.new(storage)
---> 55         return torch.stack(batch, 0, out=out)
     56     elif elem_type.__module__ == 'numpy' and elem_type.__name__ != 'str_' \
     57             and elem_type.__name__ != 'string_':

RuntimeError: stack expects each tensor to be equal size, but got [7] at entry 0 and [10] at entry 1
```

Any thoughts what this means?I Do I need padding?
2021-01-22T15:39:25Z
https://github.com/huggingface/datasets/issues/1765#issuecomment-765492647
https://api.github.com/repos/huggingface/datasets/issues/1765
MDEyOklzc3VlQ29tbWVudDc2NTQ5MjY0Nw==
https://api.github.com/repos/huggingface/datasets/issues/comments/765492647/reactions
2021-01-22T15:39:57Z
https://api.github.com/repos/huggingface/datasets/issues/comments/765492647
https://avatars.githubusercontent.com/u/1295082?v=4
https://api.github.com/users/EvanZ/events{/privacy}
https://api.github.com/users/EvanZ/followers
https://api.github.com/users/EvanZ/following{/other_user}
https://api.github.com/users/EvanZ/gists{/gist_id}
https://github.com/EvanZ
EvanZ
MDQ6VXNlcjEyOTUwODI=
https://api.github.com/users/EvanZ/orgs
https://api.github.com/users/EvanZ/received_events
https://api.github.com/users/EvanZ/repos
https://api.github.com/users/EvanZ/starred{/owner}{/repo}
https://api.github.com/users/EvanZ/subscriptions
User
https://api.github.com/users/EvanZ
public
COLLABORATOR
Yes, padding is an answer. 

This can be solved easily by passing a callable to the collate_fn arg of DataLoader that adds padding. 
2021-01-23T03:33:51Z
https://github.com/huggingface/datasets/issues/1765#issuecomment-765855796
https://api.github.com/repos/huggingface/datasets/issues/1765
MDEyOklzc3VlQ29tbWVudDc2NTg1NTc5Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/765855796/reactions
2021-01-23T11:22:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/765855796
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
NONE
Padding was the fix, thanks!
2021-01-23T03:44:14Z
https://github.com/huggingface/datasets/issues/1765#issuecomment-765858589
https://api.github.com/repos/huggingface/datasets/issues/1765
MDEyOklzc3VlQ29tbWVudDc2NTg1ODU4OQ==
https://api.github.com/repos/huggingface/datasets/issues/comments/765858589/reactions
2021-01-23T03:44:14Z
https://api.github.com/repos/huggingface/datasets/issues/comments/765858589
https://avatars.githubusercontent.com/u/1295082?v=4
https://api.github.com/users/EvanZ/events{/privacy}
https://api.github.com/users/EvanZ/followers
https://api.github.com/users/EvanZ/following{/other_user}
https://api.github.com/users/EvanZ/gists{/gist_id}
https://github.com/EvanZ
EvanZ
MDQ6VXNlcjEyOTUwODI=
https://api.github.com/users/EvanZ/orgs
https://api.github.com/users/EvanZ/received_events
https://api.github.com/users/EvanZ/repos
https://api.github.com/users/EvanZ/starred{/owner}{/repo}
https://api.github.com/users/EvanZ/subscriptions
User
https://api.github.com/users/EvanZ
public
NONE
dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_size=4)
batch = next(iter(dataloader))

getting 
ValueError: cannot reshape array of size 8192 into shape (1,512,4)

I had put padding as 2048 for encoded_dataset
kindly help
2021-12-07T12:22:33Z
https://github.com/huggingface/datasets/issues/1765#issuecomment-987876561
https://api.github.com/repos/huggingface/datasets/issues/1765
IC_kwDODunzps464czR
https://api.github.com/repos/huggingface/datasets/issues/comments/987876561/reactions
2021-12-07T12:22:33Z
https://api.github.com/repos/huggingface/datasets/issues/comments/987876561
https://avatars.githubusercontent.com/u/83825809?v=4
https://api.github.com/users/anupamadeo/events{/privacy}
https://api.github.com/users/anupamadeo/followers
https://api.github.com/users/anupamadeo/following{/other_user}
https://api.github.com/users/anupamadeo/gists{/gist_id}
https://github.com/anupamadeo
anupamadeo
MDQ6VXNlcjgzODI1ODA5
https://api.github.com/users/anupamadeo/orgs
https://api.github.com/users/anupamadeo/received_events
https://api.github.com/users/anupamadeo/repos
https://api.github.com/users/anupamadeo/starred{/owner}{/repo}
https://api.github.com/users/anupamadeo/subscriptions
User
https://api.github.com/users/anupamadeo
public
NONE
data_loader_val = torch.utils.data.DataLoader(val_dataset, batch_size=32, shuffle=True, drop_last=False, num_workers=0)
dataiter = iter(data_loader_val)
images, _ = next(dataiter)

getting -> TypeError: 'list' object is not callable

Cannot iterate through the data. Kindly suggest.
2022-10-28T02:16:38Z
https://github.com/huggingface/datasets/issues/1765#issuecomment-1294358247
https://api.github.com/repos/huggingface/datasets/issues/1765
IC_kwDODunzps5NJlbn
https://api.github.com/repos/huggingface/datasets/issues/comments/1294358247/reactions
2022-10-28T02:16:38Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1294358247
https://avatars.githubusercontent.com/u/114375002?v=4
https://api.github.com/users/arul210/events{/privacy}
https://api.github.com/users/arul210/followers
https://api.github.com/users/arul210/following{/other_user}
https://api.github.com/users/arul210/gists{/gist_id}
https://github.com/arul210
arul210
U_kgDOBtE5Wg
https://api.github.com/users/arul210/orgs
https://api.github.com/users/arul210/received_events
https://api.github.com/users/arul210/repos
https://api.github.com/users/arul210/starred{/owner}{/repo}
https://api.github.com/users/arul210/subscriptions
User
https://api.github.com/users/arul210
public
I have a Dataset that I've mapped a tokenizer over:

```
encoded_dataset.set_format(type='torch',columns=['attention_mask','input_ids','token_type_ids'])
encoded_dataset[:1]
```
```
{'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]),
 'input_ids': tensor([[  101,   178,  1198,  1400,  1714, 22233, 21365,  4515,  8618,  1113,
            102]]),
 'token_type_ids': tensor([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])}
```

When I try to iterate as in the docs, I get errors:

```
dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_sampler=32)
next(iter(dataloader))
```

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-45-05180ba8aa35> in <module>()
      1 dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_sampler=32)
----> 2 next(iter(dataloader))

3 frames
/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __init__(self, loader)
    411         self._timeout = loader.timeout
    412         self._collate_fn = loader.collate_fn
--> 413         self._sampler_iter = iter(self._index_sampler)
    414         self._base_seed = torch.empty((), dtype=torch.int64).random_(generator=loader.generator).item()
    415         self._persistent_workers = loader.persistent_workers

TypeError: 'int' object is not iterable


```