Data alteration when loading dataset with unspecified inner sequence length
MEMBER
While this issue may seem specific, it led to a silent problem in my workflow that took days to diagnose. If this feature is not intended to be supported, an error should be raised when encountering this configuration to prevent such issues.
2023-09-14T16:15:52Z
https://github.com/huggingface/datasets/issues/6242#issuecomment-1719755508
https://api.github.com/repos/huggingface/datasets/issues/6242
IC_kwDODunzps5mgWL0
https://api.github.com/repos/huggingface/datasets/issues/comments/1719755508/reactions
2023-09-14T16:15:52Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1719755508
https://avatars.githubusercontent.com/u/45557362?v=4
https://api.github.com/users/qgallouedec/events{/privacy}
https://api.github.com/users/qgallouedec/followers
https://api.github.com/users/qgallouedec/following{/other_user}
https://api.github.com/users/qgallouedec/gists{/gist_id}
https://github.com/qgallouedec
qgallouedec
MDQ6VXNlcjQ1NTU3MzYy
https://api.github.com/users/qgallouedec/orgs
https://api.github.com/users/qgallouedec/received_events
https://api.github.com/users/qgallouedec/repos
https://api.github.com/users/qgallouedec/starred{/owner}{/repo}
https://api.github.com/users/qgallouedec/subscriptions
User
https://api.github.com/users/qgallouedec
public
COLLABORATOR
Thanks for reporting! This is a MRE:

```python
import pyarrow as pa
from datasets.table import cast_array_to_feature
from datasets import Sequence, Value
data = [
    [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]],
    [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]],
]
arr = pa.array(data, pa.list_(pa.list_(pa.float32(), 3)))
cast_array_to_feature(arr, Sequence(Sequence(Value("float32"))))
```

I've opened a PR with a fix.
2023-09-15T14:27:49Z
https://github.com/huggingface/datasets/issues/6242#issuecomment-1721374146
https://api.github.com/repos/huggingface/datasets/issues/6242
IC_kwDODunzps5mmhXC
https://api.github.com/repos/huggingface/datasets/issues/comments/1721374146/reactions
2023-09-15T14:27:49Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1721374146
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
### Describe the bug

When a dataset saved with a specified inner sequence length is loaded without specifying that length, the original data is altered and becomes inconsistent.

### Steps to reproduce the bug

```python
from datasets import Dataset, Features, Value, Sequence, load_dataset

# Repository ID
repo_id = "my_repo_id"

# Define features with a specific length of 3 for each inner sequence
specified_features = Features({"key": Sequence(Sequence(Value("float32"), length=3))})

# Create a dataset with the specified features
data = [
    [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]],
    [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]],
]
dataset = Dataset.from_dict({"key": data}, features=specified_features)

# Push the dataset to the hub
dataset.push_to_hub(repo_id)

# Define features without specifying the length
unspecified_features = Features({"key": Sequence(Sequence(Value("float32")))})

# Load the dataset from the hub with this new feature definition
dataset = load_dataset(f"qgallouedec/{repo_id}", split="train", features=unspecified_features)

# The obtained data is altered
print(dataset.to_dict())  # {'key': [[[1.0], [2.0]], [[3.0], [4.0]]]}
```


### Expected behavior

```python
print(dataset.to_dict())  # {'key': [[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]]}
```

### Environment info

- `datasets` version: 2.14.4
- Platform: Linux-6.2.0-32-generic-x86_64-with-glibc2.35
- Python version: 3.9.12
- Huggingface_hub version: 0.15.1
- PyArrow version: 12.0.1
- Pandas version: 2.0.3