code: def create_log_template(request):
      from airflow import settings
      from airflow.models.tasklog import LogTemplate
  
      session = settings.Session()
  
      def _create_log_template(filename_template, elasticsearch_id=""):
          log_template = LogTemplate(
              filename=filename_template,
              elasticsearch_id=elasticsearch_id,
          )
          session.add(log_template)
          session.commit()
  
          def _delete_log_template():
              session.delete(log_template)
              session.commit()
  
          request.addfinalizer(_delete_log_template)
  
      return _create_log_template
  
imports: from __future__ import annotations
  import json
  import os
  import platform
  import subprocess
  import sys
  import warnings
  from contextlib import ExitStack, suppress
  from datetime import datetime, timedelta
  from pathlib import Path
  from typing import TYPE_CHECKING
  import pytest
  import time_machine
  from itsdangerous import URLSafeSerializer
label_desc: Use image node_id 34 for calling a global function with example usage: create_log_template(request) and returns: _create_log_template