Fix typed examples iterable state dict
State: closed | Author: lhoestq (MEMBER)

fix https://github.com/huggingface/datasets/issues/7085 as noted by @VeryLazyBoy and reported by @AjayP13

Comments: The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_7121). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

<details>
<summary>Show benchmarks</summary>

PyArrow==8.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.005273 / 0.011353 (-0.006079) | 0.003789 / 0.011008 (-0.007219) | 0.062811 / 0.038508 (0.024303) | 0.031055 / 0.023109 (0.007946) | 0.238663 / 0.275898 (-0.037235) | 0.269706 / 0.323480 (-0.053774) | 0.004105 / 0.007986 (-0.003881) | 0.002781 / 0.004328 (-0.001547) | 0.048800 / 0.004250 (0.044549) | 0.045759 / 0.037052 (0.008707) | 0.260467 / 0.258489 (0.001978) | 0.288800 / 0.293841 (-0.005041) | 0.029341 / 0.128546 (-0.099205) | 0.012413 / 0.075646 (-0.063233) | 0.203493 / 0.419271 (-0.215778) | 0.037270 / 0.043533 (-0.006263) | 0.246130 / 0.255139 (-0.009009) | 0.269046 / 0.283200 (-0.014154) | 0.017788 / 0.141683 (-0.123895) | 1.175537 / 1.452155 (-0.276617) | 1.197909 / 1.492716 (-0.294808) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.098258 / 0.018006 (0.080251) | 0.305283 / 0.000490 (0.304794) | 0.000216 / 0.000200 (0.000016) | 0.000044 / 0.000054 (-0.000010) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.019066 / 0.037411 (-0.018345) | 0.062723 / 0.014526 (0.048197) | 0.075827 / 0.176557 (-0.100730) | 0.121371 / 0.737135 (-0.615764) | 0.075167 / 0.296338 (-0.221171) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.296650 / 0.215209 (0.081441) | 2.910593 / 2.077655 (0.832939) | 1.510798 / 1.504120 (0.006678) | 1.375461 / 1.541195 (-0.165733) | 1.386423 / 1.468490 (-0.082067) | 0.743818 / 4.584777 (-3.840959) | 2.437848 / 3.745712 (-1.307864) | 2.943661 / 5.269862 (-2.326201) | 1.888977 / 4.565676 (-2.676699) | 0.080126 / 0.424275 (-0.344149) | 0.005168 / 0.007607 (-0.002439) | 0.348699 / 0.226044 (0.122654) | 3.477686 / 2.268929 (1.208758) | 1.901282 / 55.444624 (-53.543343) | 1.574847 / 6.876477 (-5.301629) | 1.594359 / 2.142072 (-0.547714) | 0.793415 / 4.805227 (-4.011812) | 0.133982 / 6.500664 (-6.366682) | 0.042435 / 0.075469 (-0.033034) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.963057 / 1.841788 (-0.878731) | 11.597217 / 8.074308 (3.522909) | 9.285172 / 10.191392 (-0.906220) | 0.130510 / 0.680424 (-0.549914) | 0.013964 / 0.534201 (-0.520237) | 0.299334 / 0.579283 (-0.279949) | 0.267775 / 0.434364 (-0.166589) | 0.336922 / 0.540337 (-0.203416) | 0.430493 / 1.386936 (-0.956443) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.005701 / 0.011353 (-0.005652) | 0.003941 / 0.011008 (-0.007067) | 0.050204 / 0.038508 (0.011696) | 0.032275 / 0.023109 (0.009166) | 0.271076 / 0.275898 (-0.004822) | 0.295565 / 0.323480 (-0.027914) | 0.004393 / 0.007986 (-0.003592) | 0.002881 / 0.004328 (-0.001447) | 0.048032 / 0.004250 (0.043782) | 0.040430 / 0.037052 (0.003378) | 0.281631 / 0.258489 (0.023142) | 0.317964 / 0.293841 (0.024124) | 0.032318 / 0.128546 (-0.096228) | 0.012348 / 0.075646 (-0.063298) | 0.060336 / 0.419271 (-0.358936) | 0.034148 / 0.043533 (-0.009385) | 0.273803 / 0.255139 (0.018664) | 0.292068 / 0.283200 (0.008868) | 0.018693 / 0.141683 (-0.122990) | 1.155704 / 1.452155 (-0.296451) | 1.192245 / 1.492716 (-0.300472) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.097588 / 0.018006 (0.079582) | 0.311760 / 0.000490 (0.311270) | 0.000232 / 0.000200 (0.000032) | 0.000055 / 0.000054 (0.000001) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.022825 / 0.037411 (-0.014586) | 0.077698 / 0.014526 (0.063172) | 0.088567 / 0.176557 (-0.087989) | 0.129689 / 0.737135 (-0.607446) | 0.090626 / 0.296338 (-0.205712) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.299791 / 0.215209 (0.084582) | 2.978558 / 2.077655 (0.900903) | 1.594095 / 1.504120 (0.089975) | 1.468476 / 1.541195 (-0.072719) | 1.482880 / 1.468490 (0.014390) | 0.717553 / 4.584777 (-3.867224) | 0.977501 / 3.745712 (-2.768211) | 2.954289 / 5.269862 (-2.315572) | 1.895473 / 4.565676 (-2.670203) | 0.078452 / 0.424275 (-0.345824) | 0.005508 / 0.007607 (-0.002099) | 0.350882 / 0.226044 (0.124837) | 3.480878 / 2.268929 (1.211949) | 1.965240 / 55.444624 (-53.479385) | 1.672448 / 6.876477 (-5.204029) | 1.674319 / 2.142072 (-0.467753) | 0.789049 / 4.805227 (-4.016178) | 0.132715 / 6.500664 (-6.367949) | 0.041081 / 0.075469 (-0.034388) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.022953 / 1.841788 (-0.818834) | 12.123349 / 8.074308 (4.049041) | 10.336115 / 10.191392 (0.144723) | 0.142233 / 0.680424 (-0.538191) | 0.015416 / 0.534201 (-0.518785) | 0.303088 / 0.579283 (-0.276195) | 0.124942 / 0.434364 (-0.309422) | 0.338454 / 0.540337 (-0.201883) | 0.460039 / 1.386936 (-0.926897) |

</details>
</details>

![](https://cml.dev/watermark.png#3813ce846e52824b38e53895810682f0a496a2e3 "CML watermark")