code: def test_window_function_cache() -> None:
      # ensures that the cache runs the flattened first (that are the sorted groups)
      # otherwise the flattened results are not ordered correctly
      out = pl.DataFrame(
          {
              "groups": ["A", "A", "B", "B", "B"],
              "groups_not_sorted": ["A", "B", "A", "B", "A"],
              "values": range(5),
          }
      ).with_columns(
          [
              pl.col("values")
              .over("groups", mapping_strategy="join")
              .alias("values_list"),  # aggregation to list + join
              pl.col("values")
              .over("groups", mapping_strategy="explode")
              .alias(
                  "values_flat"
              ),  # aggregation to list + explode and concat back
              pl.col("values")
              .reverse()
              .over("groups", mapping_strategy="explode")
              .alias(
                  "values_rev"
              ),  # use flatten to reverse within a group
          ]
      )
  
      assert out["values_list"].to_list() == [
          [0, 1],
          [0, 1],
          [2, 3, 4],
          [2, 3, 4],
          [2, 3, 4],
      ]
      assert out["values_flat"].to_list() == [0, 1, 2, 3, 4]
      assert out["values_rev"].to_list() == [1, 0, 4, 3, 2]
  
imports: from __future__ import annotations
  import numpy
  import pytest
  import polars
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 4 for calling a global function with example usage: test_window_function_cache() without return types