code: def freeze_packages_to_file(
      config_params: ConfigParams, file: TextIO
  ) -> None:
      console.print(
          f"[bright_blue]Freezing constraints to file: {file.name}"
      )
      result = run_command(
          ["pip", "freeze"],
          github_actions=config_params.github_actions,
          text=True,
          check=True,
          capture_output=True,
      )
      count_lines = 0
      for line in sorted(result.stdout.split("\n")):
          if line.startswith(
              (
                  "apache_airflow",
                  "apache-airflow==",
                  "/opt/airflow",
                  "#",
                  "-e",
              )
          ):
              continue
          if "@" in line:
              continue
          if line.strip() == "":
              continue
          count_lines += 1
          file.write(line)
          file.write("\n")
      file.flush()
      console.print(
          f"[green]Constraints generated to file: {file.name}. Wrote {count_lines} lines"
      )
  
imports: from __future__ import annotations
  import json
  import os
  import sys
  from dataclasses import dataclass
  from datetime import datetime
  from functools import cached_property
  from pathlib import Path
  from typing import TextIO
  import requests
  from click import Choice
  from in_container_utils import click, console, run_command
label_desc: Use image node_id 2 for calling a global function with example usage: freeze_packages_to_file(config_params, file) without return types