code: def test_cse_expr_selection_context(
      monkeypatch: Any, capfd: Any
  ) -> None:
      monkeypatch.setenv("POLARS_VERBOSE", "1")
      q = pl.LazyFrame(
          {
              "a": [1, 2, 3, 4],
              "b": [1, 2, 3, 4],
              "c": [1, 2, 3, 4],
          }
      )
  
      derived = (pl.col("a") * pl.col("b")).sum()
      derived2 = derived * derived
  
      exprs = [
          derived.alias("d1"),
          (derived * pl.col("c").sum() - 1).alias("foo"),
          derived2.alias("d2"),
          (derived2 * 10).alias("d3"),
      ]
  
      result = q.select(exprs).collect(comm_subexpr_elim=True)
      expected = pl.DataFrame(
          {
              "d1": [30],
              "foo": [299],
              "d2": [900],
              "d3": [9000],
          }
      )
      assert_frame_equal(result, expected)
  
      result = q.with_columns(exprs).collect(comm_subexpr_elim=True)
      expected = pl.DataFrame(
          {
              "a": [1, 2, 3, 4],
              "b": [1, 2, 3, 4],
              "c": [1, 2, 3, 4],
              "d1": [30, 30, 30, 30],
              "foo": [299, 299, 299, 299],
              "d2": [900, 900, 900, 900],
              "d3": [9000, 9000, 9000, 9000],
          }
      )
      assert_frame_equal(result, expected)
  
      out = capfd.readouterr().out
      assert "run ProjectionExec with 2 CSE" in out
      assert "run StackExec with 2 CSE" in out
  
imports: import re
  from datetime import date, datetime
  from tempfile import NamedTemporaryFile
  from typing import Any
  import numpy
  import pytest
  import polars
  from polars.testing import assert_frame_equal
label_desc: Use image node_id 7 for calling a global function with example usage: test_cse_expr_selection_context(monkeypatch, capfd) without return types