Repository: huggingface/datasets
File: src/datasets/table.py (Python)

Code before:
                    if array.null_count > 0:
                        if config.PYARROW_VERSION.major < 10:
                            warnings.warn(
                                f"None values are converted to empty lists in `pyarrow<10.0.0` when converting array to {feature}. Install `pyarrow>=10.0.0` to avoid this behavior. More info: https://github.com/huggingface/datasets/issues/3676."
                            )
                        else:
                            return pa.ListArray.from_arrays(
                                array.offsets, _c(array.values, feature.feature), mask=array.is_null()
                            )
                    return pa.ListArray.from_arrays(array.offsets, _c(array.values, feature.feature))
    elif pa.types.is_fixed_size_list(array.type):
        # feature must be either [subfeature] or Sequence(subfeature)
        array_values = array.values
        if isinstance(feature, list):
            if array.null_count > 0:
                if config.PYARROW_VERSION.major < 10:
                    warnings.warn(
                        f"None values are converted to empty lists when converting array to {feature}. Install `pyarrow>=10.0.0` to avoid this behavior. More info: https://github.com/huggingface/datasets/issues/3676. This will raise an error in a future major version of `datasets`"
                    )
                else:
                    return pa.ListArray.from_arrays(array.offsets, _c(array_values, feature[0]), mask=array.is_null())
            return pa.ListArray.from_arrays(array.offsets, _c(array_values, feature[0]))
        elif isinstance(feature, Sequence):
            if feature.length > -1:
                if array.offset and feature.length * len(array) != len(array_values):
                    array_values = array.values[array.offset * array.type.list_size :]
                if feature.length * len(array) == len(array_values):
                    return pa.FixedSizeListArray.from_arrays(_c(array_values, feature.feature), feature.length)
            else:
                offsets_arr = pa.array(np.arange(len(array) + 1) * array.type.list_size, pa.int32())
                if array.null_count > 0:
                    if config.PYARROW_VERSION.major < 10:
                        warnings.warn(
                            f"None values are converted to empty lists when converting array to {feature}. Install `pyarrow>=10.0.0` to avoid this behavior. More info: https://github.com/huggingface/datasets/issues/3676. This will raise an error in a future major version of `datasets`"
                        )
                    else:
                        return pa.ListArray.from_arrays(
                            offsets_arr, _c(array_values, feature.feature), mask=array.is_null()
                        )
                return pa.ListArray.from_arrays(offsets_arr, _c(array_values, feature.feature))
    if pa.types.is_null(array.type):
        return array_cast(array, get_nested_type(feature), allow_number_to_str=allow_number_to_str)
    elif not isinstance(feature, (Sequence, dict, list, tuple)):
        return array_cast(array, feature(), allow_number_to_str=allow_number_to_str)
    raise TypeError(f"Couldn't cast array of type\n{array.type}\nto\n{feature}")


@_wrap_for_chunked_arrays
def embed_array_storage(array: pa.Array, feature: "FeatureType"):
    """Embed data into an arrays's storage.
    For custom features like Audio or Image, it takes into account the "embed_storage" methods

Review comment (suggestion):
We also need to specify where the slice ends, no?

```suggestion
                    array_values = array.values[array.offset * array.type.list_size : (array.offset + len(array)) * array.type.list_size]
```

Code after:
                    if array.null_count > 0:
                        if config.PYARROW_VERSION.major < 10:
                            warnings.warn(
                                f"None values are converted to empty lists in `pyarrow<10.0.0` when converting array to {feature}. Install `pyarrow>=10.0.0` to avoid this behavior. More info: https://github.com/huggingface/datasets/issues/3676."
                            )
                        else:
                            return pa.ListArray.from_arrays(
                                array.offsets, _c(array.values, feature.feature), mask=array.is_null()
                            )
                    return pa.ListArray.from_arrays(array.offsets, _c(array.values, feature.feature))
    elif pa.types.is_fixed_size_list(array.type):
        # feature must be either [subfeature] or Sequence(subfeature)
        array_values = array.values
        if isinstance(feature, list):
            if array.null_count > 0:
                if config.PYARROW_VERSION.major < 10:
                    warnings.warn(
                        f"None values are converted to empty lists when converting array to {feature}. Install `pyarrow>=10.0.0` to avoid this behavior. More info: https://github.com/huggingface/datasets/issues/3676. This will raise an error in a future major version of `datasets`"
                    )
                else:
                    return pa.ListArray.from_arrays(array.offsets, _c(array_values, feature[0]), mask=array.is_null())
            return pa.ListArray.from_arrays(array.offsets, _c(array_values, feature[0]))
        elif isinstance(feature, Sequence):
            if feature.length > -1:
                if array.offset and feature.length * len(array) != len(array_values):
                    array_values = array.values[
                        array.offset * array.type.list_size : (array.offset + len(array)) * array.type.list_size
                    ]
                if feature.length * len(array) == len(array_values):
                    return pa.FixedSizeListArray.from_arrays(_c(array_values, feature.feature), feature.length)
            else:
                offsets_arr = pa.array(np.arange(len(array) + 1) * array.type.list_size, pa.int32())
                if array.null_count > 0:
                    if config.PYARROW_VERSION.major < 10:
                        warnings.warn(
                            f"None values are converted to empty lists when converting array to {feature}. Install `pyarrow>=10.0.0` to avoid this behavior. More info: https://github.com/huggingface/datasets/issues/3676. This will raise an error in a future major version of `datasets`"
                        )
                    else:
                        return pa.ListArray.from_arrays(
                            offsets_arr, _c(array_values, feature.feature), mask=array.is_null()
                        )
                return pa.ListArray.from_arrays(offsets_arr, _c(array_values, feature.feature))
    if pa.types.is_null(array.type):
        return array_cast(array, get_nested_type(feature), allow_number_to_str=allow_number_to_str)
    elif not isinstance(feature, (Sequence, dict, list, tuple)):
        return array_cast(array, feature(), allow_number_to_str=allow_number_to_str)
    raise TypeError(f"Couldn't cast array of type\n{array.type}\nto\n{feature}")


@_wrap_for_chunked_arrays
def embed_array_storage(array: pa.Array, feature: "FeatureType"):