cast_column to Sequence(subfeatures_dict) has err
COLLABORATOR
Hi! You are passing the wrong feature type to `cast_column`. This is the fixed call:
```python
ais_dataset = ais_dataset.cast_column("my_labeled_bbox", {"bbox": Sequence(Value(dtype="int64")), "label": ClassLabel(names=["cat", "dog"])})
```
2024-01-24T18:40:31Z
https://github.com/huggingface/datasets/issues/6610#issuecomment-1908713896
https://api.github.com/repos/huggingface/datasets/issues/6610
IC_kwDODunzps5xxKmo
https://api.github.com/repos/huggingface/datasets/issues/comments/1908713896/reactions
2024-01-24T18:40:31Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1908713896
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
> Hi! You are passing the wrong feature type to `cast_column`. This is the fixed call:
> 
> ```python
> ais_dataset = ais_dataset.cast_column("my_labeled_bbox", {"bbox": Sequence(Value(dtype="int64")), "label": ClassLabel(names=["cat", "dog"])})
> ```

thanks
2024-01-25T02:15:23Z
https://github.com/huggingface/datasets/issues/6610#issuecomment-1909232598
https://api.github.com/repos/huggingface/datasets/issues/6610
IC_kwDODunzps5xzJPW
https://api.github.com/repos/huggingface/datasets/issues/comments/1909232598/reactions
2024-01-25T02:15:23Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1909232598
https://avatars.githubusercontent.com/u/16574677?v=4
https://api.github.com/users/neiblegy/events{/privacy}
https://api.github.com/users/neiblegy/followers
https://api.github.com/users/neiblegy/following{/other_user}
https://api.github.com/users/neiblegy/gists{/gist_id}
https://github.com/neiblegy
neiblegy
MDQ6VXNlcjE2NTc0Njc3
https://api.github.com/users/neiblegy/orgs
https://api.github.com/users/neiblegy/received_events
https://api.github.com/users/neiblegy/repos
https://api.github.com/users/neiblegy/starred{/owner}{/repo}
https://api.github.com/users/neiblegy/subscriptions
User
https://api.github.com/users/neiblegy
public
### Describe the bug

I am working with the following demo code:
```
from datasets import load_dataset
from datasets.features import Sequence, Value, ClassLabel, Features

ais_dataset = load_dataset("/data/ryan.gao/ais_dataset_cache/raw/1978/")
ais_dataset = ais_dataset["train"]

def add_class(example):
    example["my_labeled_bbox"] = {"bbox": [100,100,200,200], "label": "cat"}
    return example

ais_dataset = ais_dataset.map(add_class, batched=False, num_proc=32)
ais_dataset = ais_dataset.cast_column("my_labeled_bbox", Sequence(
                                                        {
                                                            "bbox": Sequence(Value(dtype="int64")),
                                                            "label": ClassLabel(names=["cat", "dog"])
                                                        }))

print(ais_dataset[0])
```
However, executing this code results in an error:

```
  File "/home/protoss.gao/.local/lib/python3.9/site-packages/datasets/table.py", line 2111, in cast_array_to_feature
    raise TypeError(f"Couldn't cast array of type\n{array.type}\nto\n{feature}")
TypeError: Couldn't cast array of type
int64
to
Sequence(feature=Value(dtype='int64', id=None), length=-1, id=None)
```
Upon examining the source code in datasets/table.py at line 2035:

```
        if isinstance(feature, Sequence) and isinstance(feature.feature, dict):
            feature = {
                name: Sequence(subfeature, length=feature.length) for name, subfeature in feature.feature.items()
            }
```

I noticed that if subfeature is of type Sequence, the code results in Sequence(Sequence(...), ...) and Sequence(ClassLabel(...), ...), which appears to be the source of the error.


### Steps to reproduce the bug

run my demo code

### Expected behavior

no exception

### Environment info

python 3.9 
datasets: 2.16.1