code: def test_window_filtered_aggregation() -> None:
      df = pl.DataFrame(
          {
              "group": ["A", "A", "B", "B"],
              "field1": [2, 4, 6, 8],
              "flag": [1, 0, 1, 1],
          }
      )
      out = df.with_columns(
          pl.col("field1")
          .filter(pl.col("flag") == 1)
          .mean()
          .over("group")
          .alias("mean")
      )
      expected = pl.DataFrame(
          {
              "group": ["A", "A", "B", "B"],
              "field1": [2, 4, 6, 8],
              "flag": [1, 0, 1, 1],
              "mean": [2.0, 2.0, 7.0, 7.0],
          }
      )
      assert_frame_equal(out, expected)
  
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 17 for calling a global function with example usage: test_window_filtered_aggregation() without return types