code: def test_nested_categorical_aggregation_7848() -> None:
      # a double categorical aggregation
      assert pl.DataFrame(
          {
              "group": [1, 1, 2, 2, 2, 3, 3],
              "letter": ["a", "b", "c", "d", "e", "f", "g"],
          }
      ).with_columns([pl.col("letter").cast(pl.Categorical)]).group_by(
          maintain_order=True, by=["group"]
      ).all().with_columns(
          pl.col("letter").list.len().alias("c_group")
      ).group_by(
          by=["c_group"], maintain_order=True
      ).agg(
          pl.col("letter")
      ).to_dict(
          as_series=False
      ) == {
          "c_group": [2, 3],
          "letter": [[["a", "b"], ["f", "g"]], [["c", "d", "e"]]],
      }
  
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 27 for calling a global function with example usage: test_nested_categorical_aggregation_7848() without return types