code: def test_cast_inner_categorical() -> None:
      dtype = pl.List(pl.Categorical)
      out = pl.Series("foo", [["a"], ["a", "b"]]).cast(dtype)
      assert out.dtype == dtype
      assert out.to_list() == [["a"], ["a", "b"]]
  
      with pytest.raises(
          pl.ComputeError,
          match=r"casting to categorical not allowed in `list.eval`",
      ):
          pl.Series("foo", [["a", "b"], ["a", "b"]]).list.eval(
              pl.element().cast(pl.Categorical)
          )
  
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 21 for calling a global function with example usage: test_cast_inner_categorical() without return types