TypeError: 'bool' object is not iterable when filtering a datasets.arrow_dataset.Dataset
{'login': 'vmuel', 'id': 91255010, 'node_id': 'MDQ6VXNlcjkxMjU1MDEw', 'avatar_url': 'https://avatars.githubusercontent.com/u/91255010?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/vmuel', 'html_url': 'https://github.com/vmuel', 'followers_url': 'https://api.github.com/users/vmuel/followers', 'following_url': 'https://api.github.com/users/vmuel/following{/other_user}', 'gists_url': 'https://api.github.com/users/vmuel/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/vmuel/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/vmuel/subscriptions', 'organizations_url': 'https://api.github.com/users/vmuel/orgs', 'repos_url': 'https://api.github.com/users/vmuel/repos', 'events_url': 'https://api.github.com/users/vmuel/events{/privacy}', 'received_events_url': 'https://api.github.com/users/vmuel/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Hi! Instead of a single boolean, your filter function should return an iterable (of booleans) in the batched mode like so:
```python
train_dataset = train_dataset.filter(
            function=lambda batch: [image is not None for image in batch["image"]], 
            batched=True,
            batch_size=10)
```

PS: You can make this operation much faster by operating directly on the arrow data to skip the decoding part:
```python
train_dataset = train_dataset.with_format("arrow")
train_dataset = train_dataset.filter(
            function=lambda table: table["image"].is_valid().to_pylist(), 
            batched=True,
            batch_size=100)
train_dataset = train_dataset.with_format(None)
``` Thank a lot!
### Describe the bug

Hi, 

Thanks for the amazing work on the library!

**Describe the bug**

I think I might have noticed a small bug in the filter method. 
Having loaded a dataset using `load_dataset`,  when I try to filter out empty entries with `batched=True`, I get a TypeError.

### Steps to reproduce the bug

```
train_dataset = train_dataset.filter(
            function=lambda example: example["image"] is not None, 
            batched=True,
            batch_size=10)
```
Error message:

```
File .../lib/python3.9/site-packages/datasets/fingerprint.py:480, in fingerprint_transform.<locals>._fingerprint.<locals>.wrapper(*args, **kwargs)
    476             validate_fingerprint(kwargs[fingerprint_name])
    478 # Call actual function
--> 480 out = func(self, *args, **kwargs)
...
-> 5666 indices_array = [i for i, to_keep in zip(indices, mask) if to_keep]
   5667 if indices_mapping is not None:
   5668     indices_array = pa.array(indices_array, type=pa.uint64())

TypeError: 'bool' object is not iterable
```

**Removing batched=True allows to bypass the issue.** 

### Expected behavior

According to the doc, "[batch_size corresponds to the] number of examples per batch provided to function if batched = True", so we shouldn't need to remove the batchd=True arg?

source: https://huggingface.co/docs/datasets/v2.9.0/en/package_reference/main_classes#datasets.Dataset.filter

### Environment info

- `datasets` version: 2.9.0
- Platform: Linux-5.4.0-122-generic-x86_64-with-glibc2.31
- Python version: 3.9.10
- PyArrow version: 10.0.1
- Pandas version: 1.5.3
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/5498/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}