code: def test_cat_to_dummies() -> None:
      df = pl.DataFrame(
          {"foo": [1, 2, 3, 4], "bar": ["a", "b", "a", "c"]}
      )
      df = df.with_columns(pl.col("bar").cast(pl.Categorical))
      assert df.to_dummies().to_dict(as_series=False) == {
          "foo_1": [1, 0, 0, 0],
          "foo_2": [0, 1, 0, 0],
          "foo_3": [0, 0, 1, 0],
          "foo_4": [0, 0, 0, 1],
          "bar_a": [1, 0, 1, 0],
          "bar_b": [0, 1, 0, 0],
          "bar_c": [0, 0, 0, 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 3 for calling a global function with example usage: test_cat_to_dummies() without return types