Saving a dataset after setting format to torch doesn't work, but only if filtering
{'login': 'joebhakim', 'id': 13984157, 'node_id': 'MDQ6VXNlcjEzOTg0MTU3', 'avatar_url': 'https://avatars.githubusercontent.com/u/13984157?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/joebhakim', 'html_url': 'https://github.com/joebhakim', 'followers_url': 'https://api.github.com/users/joebhakim/followers', 'following_url': 'https://api.github.com/users/joebhakim/following{/other_user}', 'gists_url': 'https://api.github.com/users/joebhakim/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/joebhakim/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/joebhakim/subscriptions', 'organizations_url': 'https://api.github.com/users/joebhakim/orgs', 'repos_url': 'https://api.github.com/users/joebhakim/repos', 'events_url': 'https://api.github.com/users/joebhakim/events{/privacy}', 'received_events_url': 'https://api.github.com/users/joebhakim/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Hey, I'm a research engineer working on language modelling wanting to contribute to open source. I was wondering if I could give it a shot? Hi! This issue was fixed in https://github.com/huggingface/datasets/pull/4972, so please install `datasets>=2.5.0` to avoid it.
### Describe the bug

Saving a dataset after setting format to torch doesn't work, but only if filtering

### Steps to reproduce the bug

```
a = Dataset.from_dict({"b": [1, 2]})
a.set_format('torch')
a.save_to_disk("test_save") # saves successfully
a.filter(None).save_to_disk("test_save_filter") # does not
>> [...] TypeError: Provided `function` which is applied to all elements of table returns a `dict` of types [<class 'torch.Tensor'>]. When using `batched=True`, make sure provided `function` returns a `dict` of types like `(<class 'list'>, <class 'numpy.ndarray'>)`.

# note: skipping the format change to torch lets this work.



### Expected behavior

Saving to work

### Environment info

- `datasets` version: 2.4.0
- Platform: Linux-6.1.9-arch1-1-x86_64-with-glibc2.36
- Python version: 3.10.9
- PyArrow version: 9.0.0
- Pandas version: 1.4.4
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/5508/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}