code: def render(
      template_path: Union[Path, str],
      output_path: Optional[Union[Path, str]] = None,
      template_variables: Optional[Dict[str, Any]] = None,
  ) -> str:
      """Renders a Jinja template and returns the content as a string.
  
      Args:
        template_path: The path to a Jinja template file.
        output_path: The path to write the rendered template to. If not provided,
          the rendered template will not be written to a file. If the file already
          exists, it will be overwritten.
        template_variables: A dictionary of variables to pass to the template.
      """
      template_variables = template_variables or {}
      template_dir = os.path.dirname(template_path)
      template_file = os.path.basename(template_path)
      jinja_env = jinja2.Environment(
          loader=jinja2.FileSystemLoader(template_dir),
          autoescape=True,
          auto_reload=True,
          cache_size=0,
      )
  
      template = jinja_env.get_template(template_file)
      content = template.render(template_variables)
      if output_path:
          io_utils.write_file(output_path, content)
  
      return content
  
file_path: model-card-toolkit/model_card_toolkit/utils/template_utils.py
imports: import os
  from pathlib import Path
  from typing import Any, Dict, Optional, Union
  import jinja2
  from model_card_toolkit.utils import io_utils
label_desc: Use image node_id 3 for calling a global function with example usage: render(template_path, output_path, template_variables) and returns: content