code: def _build_theme_template(
      template_name: str,
      env: jinja2.Environment,
      files: Files,
      config: MkDocsConfig,
      nav: Navigation,
  ) -> None:
      """Build a template using the theme environment."""
      log.debug(f"Building theme template: {template_name}")
  
      try:
          template = env.get_template(template_name)
      except TemplateNotFound:
          log.warning(
              f"Template skipped: '{template_name}' not found in theme directories."
          )
          return
  
      output = _build_template(
          template_name, template, files, config, nav
      )
  
      if output.strip():
          output_path = os.path.join(config.site_dir, template_name)
          utils.write_file(output.encode("utf-8"), output_path)
  
          if template_name == "sitemap.xml":
              log.debug(f"Gzipping template: {template_name}")
              gz_filename = f"{output_path}.gz"
              with open(gz_filename, "wb") as f:
                  timestamp = utils.get_build_timestamp(
                      pages=[
                          f.page
                          for f in files.documentation_pages()
                          if f.page is not None
                      ]
                  )
                  with gzip.GzipFile(
                      fileobj=f,
                      filename=gz_filename,
                      mode="wb",
                      mtime=timestamp,
                  ) as gz_buf:
                      gz_buf.write(output.encode("utf-8"))
      else:
          log.info(
              f"Template skipped: '{template_name}' generated empty output."
          )
  
imports: from __future__ import annotations
  import gzip
  import logging
  import os
  import time
  from typing import TYPE_CHECKING, Sequence
  from urllib.parse import urljoin, urlsplit
  import jinja2
  from jinja2.exceptions import TemplateNotFound
  import mkdocs
  from mkdocs import utils
  from mkdocs.exceptions import Abort, BuildError
  from mkdocs.structure.files import File, Files, InclusionLevel, get_files, set_exclusions
  from mkdocs.structure.nav import Navigation, get_navigation
  from mkdocs.structure.pages import Page
  from mkdocs.utils import DuplicateFilter
  from mkdocs.utils import templates
label_desc: Use image node_id 3 for calling a global function with example usage: _build_theme_template(template_name, env, files, config, nav) without return types