code: def test_struct_categorical_5843() -> None:
      df = pl.DataFrame({"foo": ["a", "b", "c", "a"]}).with_columns(
          pl.col("foo").cast(pl.Categorical)
      )
      result = df.select(pl.col("foo").value_counts(sort=True))
      assert result.to_dict(as_series=False) == {
          "foo": [
              {"foo": "a", "count": 2},
              {"foo": "b", "count": 1},
              {"foo": "c", "count": 1},
          ]
      }
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from datetime import datetime, time
  from typing import TYPE_CHECKING
  import pandas
  import pyarrow
  import pytest
  import polars
  import polars.selectors
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 33 for calling a global function with example usage: test_struct_categorical_5843() without return types