Type error when calling `map` over dataset containing 0-d tensors
{'login': 'phipsgabler', 'id': 7878215, 'node_id': 'MDQ6VXNlcjc4NzgyMTU=', 'avatar_url': 'https://avatars.githubusercontent.com/u/7878215?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/phipsgabler', 'html_url': 'https://github.com/phipsgabler', 'followers_url': 'https://api.github.com/users/phipsgabler/followers', 'following_url': 'https://api.github.com/users/phipsgabler/following{/other_user}', 'gists_url': 'https://api.github.com/users/phipsgabler/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/phipsgabler/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/phipsgabler/subscriptions', 'organizations_url': 'https://api.github.com/users/phipsgabler/orgs', 'repos_url': 'https://api.github.com/users/phipsgabler/repos', 'events_url': 'https://api.github.com/users/phipsgabler/events{/privacy}', 'received_events_url': 'https://api.github.com/users/phipsgabler/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Hi! 

We could address this by calling `.item()` on such tensors to extract the value, but this would lose us the type, which could lead to storing the generated dataset in a suboptimal format. Considering this, I think the only proper fix would be implementing support for 0-D tensors on Apache Arrow's side (Arrow is the underlying format we use to store datasets on disk/in memory). WDYT @lhoestq? I think we can just convert the item to a numpy typed scalar using `.numpy()` ?

For example this works:
```python
import numpy as np
import pyarrow as pa

assert pa.array([np.float64(1.0)]).type == pa.float64()
assert pa.array([np.float32(1.0)]).type == pa.float32()
assert pa.array([np.int32(1)]).type == pa.int32()
assert pa.array([np.int64(1)]).type == pa.int64()
```

And therefore it would work the same as for PyTorch N-D Tensors: convert to Numpy Array to keep the type in `_cast_to_python_objects`, then convert to Arrow
### Describe the bug

0-dimensional tensors in a dataset lead to `TypeError: iteration over a 0-d array` when calling `map`.  It is easy to generate such tensors by using `.with_format("...")` on the whole dataset.

### Steps to reproduce the bug

```
ds = datasets.Dataset.from_list([{"a": 1}, {"a": 1}]).with_format("torch")
ds.map(None)
```

### Expected behavior

Getting back `ds` without errors.

### Environment info

Python 3.10.8
datasets 2.6.
torch 1.13.0
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/5229/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}