code: def write_python_script(
      jinja_context: dict,
      filename: str,
      render_template_as_native_obj: bool = False,
  ):
      """
      Render the python script to a file to execute in the virtual environment.
  
      :param jinja_context: The jinja context variables to unpack and replace with its placeholders in the
          template file.
      :param filename: The name of the file to dump the rendered script to.
      :param render_template_as_native_obj: If ``True``, rendered Jinja template would be converted
          to a native Python object
      """
      template_loader = jinja2.FileSystemLoader(
          searchpath=os.path.dirname(__file__)
      )
      template_env: jinja2.Environment
      if render_template_as_native_obj:
          template_env = jinja2.nativetypes.NativeEnvironment(
              loader=template_loader, undefined=jinja2.StrictUndefined
          )
      else:
          template_env = jinja2.Environment(
              loader=template_loader,
              undefined=jinja2.StrictUndefined,
              autoescape=select_autoescape(["html", "xml"]),
          )
      template = template_env.get_template(
          "python_kubernetes_script.jinja2"
      )
      template.stream(**jinja_context).dump(filename)
  
file_path: airflow/airflow/providers/cncf/kubernetes/python_kubernetes_script.py
imports: from __future__ import annotations
  import os
  from collections import deque
  import jinja2
  from jinja2 import select_autoescape
label_desc: Use image node_id 3 for calling a global function with example usage: write_python_script(jinja_context, filename, render_template_as_native_obj) without return types