Fix `to_numpy` when None values in the sequence

Closes #5927 
I've realized that the error was overlooked during testing due to the presence of only one None value in the sequence.
Unfortunately, it was the only case where the function works as expected. When the sequence contained more than one None value, the function failed. Consequently, I've updated the tests to include sequences with multiple None values.


I just added the same test with dynamic shape

_The documentation is not available anymore as the PR was closed or merged._

Awesome ! I'm merging now if you don't mind :)
We should probably give you permissions to merge your own PRs when you have an approval

<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.009980 / 0.011353 (-0.001373) | 0.005709 / 0.011008 (-0.005300) | 0.132185 / 0.038508 (0.093677) | 0.039299 / 0.023109 (0.016190) | 0.400168 / 0.275898 (0.124270) | 0.470582 / 0.323480 (0.147102) | 0.007753 / 0.007986 (-0.000233) | 0.005196 / 0.004328 (0.000868) | 0.093698 / 0.004250 (0.089448) | 0.052631 / 0.037052 (0.015579) | 0.430347 / 0.258489 (0.171858) | 0.460162 / 0.293841 (0.166321) | 0.057511 / 0.128546 (-0.071035) | 0.013944 / 0.075646 (-0.061702) | 0.459008 / 0.419271 (0.039737) | 0.075532 / 0.043533 (0.031999) | 0.405165 / 0.255139 (0.150026) | 0.456142 / 0.283200 (0.172942) | 0.117309 / 0.141683 (-0.024374) | 1.945787 / 1.452155 (0.493633) | 2.067162 / 1.492716 (0.574446) |

### 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.285755 / 0.018006 (0.267749) | 0.619965 / 0.000490 (0.619476) | 0.005071 / 0.000200 (0.004871) | 0.000114 / 0.000054 (0.000059) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.031112 / 0.037411 (-0.006299) | 0.128514 / 0.014526 (0.113988) | 0.137161 / 0.176557 (-0.039396) | 0.211363 / 0.737135 (-0.525772) | 0.151045 / 0.296338 (-0.145293) |

### 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.609361 / 0.215209 (0.394152) | 6.124844 / 2.077655 (4.047189) | 2.440757 / 1.504120 (0.936637) | 2.034495 / 1.541195 (0.493300) | 2.047192 / 1.468490 (0.578702) | 0.883171 / 4.584777 (-3.701606) | 5.470552 / 3.745712 (1.724840) | 4.401696 / 5.269862 (-0.868165) | 2.378674 / 4.565676 (-2.187003) | 0.108065 / 0.424275 (-0.316210) | 0.013239 / 0.007607 (0.005632) | 0.830957 / 0.226044 (0.604913) | 8.090659 / 2.268929 (5.821731) | 3.289203 / 55.444624 (-52.155422) | 2.500777 / 6.876477 (-4.375700) | 2.561440 / 2.142072 (0.419367) | 1.064893 / 4.805227 (-3.740334) | 0.220486 / 6.500664 (-6.280178) | 0.079507 / 0.075469 (0.004038) |

### 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.544334 / 1.841788 (-0.297454) | 17.878997 / 8.074308 (9.804689) | 18.952191 / 10.191392 (8.760799) | 0.245166 / 0.680424 (-0.435258) | 0.028022 / 0.534201 (-0.506179) | 0.517828 / 0.579283 (-0.061455) | 0.618988 / 0.434364 (0.184624) | 0.589742 / 0.540337 (0.049405) | 0.670902 / 1.386936 (-0.716034) |

</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.009616 / 0.011353 (-0.001737) | 0.006098 / 0.011008 (-0.004911) | 0.100301 / 0.038508 (0.061793) | 0.037792 / 0.023109 (0.014683) | 0.484667 / 0.275898 (0.208769) | 0.519286 / 0.323480 (0.195806) | 0.007427 / 0.007986 (-0.000558) | 0.007172 / 0.004328 (0.002844) | 0.104429 / 0.004250 (0.100179) | 0.056567 / 0.037052 (0.019515) | 0.502641 / 0.258489 (0.244152) | 0.549629 / 0.293841 (0.255788) | 0.049574 / 0.128546 (-0.078972) | 0.015223 / 0.075646 (-0.060424) | 0.113947 / 0.419271 (-0.305324) | 0.064585 / 0.043533 (0.021053) | 0.512962 / 0.255139 (0.257823) | 0.507218 / 0.283200 (0.224019) | 0.122194 / 0.141683 (-0.019488) | 1.927821 / 1.452155 (0.475667) | 2.051161 / 1.492716 (0.558445) |

### 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.291350 / 0.018006 (0.273344) | 0.588099 / 0.000490 (0.587610) | 0.001368 / 0.000200 (0.001168) | 0.000153 / 0.000054 (0.000099) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.030604 / 0.037411 (-0.006807) | 0.126810 / 0.014526 (0.112285) | 0.139309 / 0.176557 (-0.037248) | 0.208030 / 0.737135 (-0.529105) | 0.138985 / 0.296338 (-0.157353) |

### 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.681254 / 0.215209 (0.466045) | 6.753856 / 2.077655 (4.676201) | 2.780704 / 1.504120 (1.276585) | 2.475205 / 1.541195 (0.934010) | 2.486784 / 1.468490 (1.018294) | 0.879223 / 4.584777 (-3.705554) | 5.662294 / 3.745712 (1.916582) | 2.698705 / 5.269862 (-2.571156) | 1.660620 / 4.565676 (-2.905057) | 0.112218 / 0.424275 (-0.312057) | 0.014211 / 0.007607 (0.006604) | 0.796957 / 0.226044 (0.570913) | 8.180897 / 2.268929 (5.911969) | 3.540419 / 55.444624 (-51.904205) | 2.899467 / 6.876477 (-3.977010) | 2.870306 / 2.142072 (0.728233) | 1.069537 / 4.805227 (-3.735690) | 0.211281 / 6.500664 (-6.289383) | 0.078898 / 0.075469 (0.003429) |

### 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.666790 / 1.841788 (-0.174998) | 18.302127 / 8.074308 (10.227819) | 21.317546 / 10.191392 (11.126153) | 0.242795 / 0.680424 (-0.437629) | 0.026754 / 0.534201 (-0.507447) | 0.493375 / 0.579283 (-0.085908) | 0.605400 / 0.434364 (0.171036) | 0.586888 / 0.540337 (0.046550) | 0.722809 / 1.386936 (-0.664127) |

</details>
</details>

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