code: def generate_redirects(app):
      path = os.path.join(app.srcdir, app.config.redirects_file)
      if not os.path.exists(path):
          logger.warning("Could not find redirects file at '%s'" % path)
          return
  
      if not type(app.builder) == builders.StandaloneHTMLBuilder:
          logger.warning(
              "Page redirection is only supported for the 'html' builder. "
              "Skipping..."
          )
          return
  
      with open(path) as redirects:
          for line in redirects.readlines():
              line = line.strip()
              if not line or line.startswith("#"):
                  continue
  
              from_path, to_path = line.split()
  
              from_html_path = os.path.splitext(from_path)[0] + ".html"
  
              to_path_prefix = (
                  "..%s"
                  % os.path.sep
                  * (len(from_html_path.split(os.path.sep)) - 1)
              )
              to_html_path = (
                  to_path_prefix
                  + os.path.splitext(to_path)[0]
                  + ".html"
              )
  
              logger.info(
                  "Redirecting '%s' to '%s'"
                  % (from_html_path, to_html_path)
              )
  
              redirect_path = os.path.join(
                  app.builder.outdir, from_html_path
              )
              etau.write_file(
                  _REDIRECT_TEMPLATE.format(url=to_html_path),
                  redirect_path,
              )
  
imports: import os
  from sphinx.builders import html
  from sphinx.util import logging
  import eta.core.utils
label_desc: Use image node_id 1 for calling a global function with example usage: generate_redirects(app) without return types