code: def test_struct_categorical_nesting() -> None:
      # this triggers a lot of materialization
      df = pl.DataFrame(
          {"cats": ["Value1", "Value2", "Value1"]},
          schema_overrides={"cats": pl.Categorical},
      )
      s = df.select(pl.struct(pl.col("cats")))["cats"].implode()
      assert s.dtype == pl.List(
          pl.Struct([pl.Field("cats", pl.Categorical)])
      )
      # triggers recursive conversion
      assert s.to_list() == [
          [{"cats": "Value1"}, {"cats": "Value2"}, {"cats": "Value1"}]
      ]
      # triggers different recursive conversion
      assert len(s.to_arrow()) == 1
  
imports: from __future__ import annotations
  import contextlib
  import io
  import operator
  from typing import TYPE_CHECKING, Any, Callable, Literal
  import pytest
  import polars
  from polars import StringCache
  from polars.exceptions import CategoricalRemappingWarning, StringCacheMismatchError
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 29 for calling a global function with example usage: test_struct_categorical_nesting() without return types