code: def _stream(
      app: Flask, template: Template, context: dict[str, t.Any]
  ) -> t.Iterator[str]:
      app.update_template_context(context)
      before_render_template.send(
          app,
          _async_wrapper=app.ensure_sync,
          template=template,
          context=context,
      )
  
      def generate() -> t.Iterator[str]:
          yield from template.generate(context)
          template_rendered.send(
              app,
              _async_wrapper=app.ensure_sync,
              template=template,
              context=context,
          )
  
      rv = generate()
  
      # If a request context is active, keep it while generating.
      if request:
          rv = stream_with_context(rv)
  
      return rv
  
imports: from __future__ import annotations
  import typing
  from jinja2 import BaseLoader
  from jinja2 import Environment
  from jinja2 import Template
  from jinja2 import TemplateNotFound
  from .globals import _cv_app
  from .globals import _cv_request
  from .globals import current_app
  from .globals import request
  from .helpers import stream_with_context
  from .signals import before_render_template
  from .signals import template_rendered
label_desc: Use image node_id 5 for calling a global function with example usage: _stream(app, template, context) and returns: rv