code: def select_autoescape(
      enabled_extensions: t.Collection[str] = ("html", "htm", "xml"),
      disabled_extensions: t.Collection[str] = (),
      default_for_string: bool = True,
      default: bool = False,
  ) -> t.Callable[[t.Optional[str]], bool]:
      """Intelligently sets the initial value of autoescaping based on the
      filename of the template.  This is the recommended way to configure
      autoescaping if you do not want to write a custom function yourself.
  
      If you want to enable it for all templates created from strings or
      for all templates with `.html` and `.xml` extensions::
  
          from jinja2 import Environment, select_autoescape
          env = Environment(autoescape=select_autoescape(
              enabled_extensions=('html', 'xml'),
              default_for_string=True,
          ))
  
      Example configuration to turn it on at all times except if the template
      ends with `.txt`::
  
          from jinja2 import Environment, select_autoescape
          env = Environment(autoescape=select_autoescape(
              disabled_extensions=('txt',),
              default_for_string=True,
              default=True,
          ))
  
      The `enabled_extensions` is an iterable of all the extensions that
      autoescaping should be enabled for.  Likewise `disabled_extensions` is
      a list of all templates it should be disabled for.  If a template is
      loaded from a string then the default from `default_for_string` is used.
      If nothing matches then the initial value of autoescaping is set to the
      value of `default`.
  
      For security reasons this function operates case insensitive.
  
      .. versionadded:: 2.9
      """
      enabled_patterns = tuple(
          f".{x.lstrip('.').lower()}" for x in enabled_extensions
      )
      disabled_patterns = tuple(
          f".{x.lstrip('.').lower()}" for x in disabled_extensions
      )
  
      def autoescape(template_name: t.Optional[str]) -> bool:
          if template_name is None:
              return default_for_string
          template_name = template_name.lower()
          if template_name.endswith(enabled_patterns):
              return True
          if template_name.endswith(disabled_patterns):
              return False
          return default
  
      return autoescape
  
imports: import enum
  import json
  import os
  import re
  import typing
  from collections import abc
  from collections import deque
  from random import choice
  from random import randrange
  from threading import Lock
  from types import CodeType
  from urllib.parse import quote_from_bytes
  import markupsafe
label_desc: Use image node_id 15 for calling a global function with example usage: select_autoescape(enabled_extensions, disabled_extensions, default_for_string, default) and returns: autoescape, default, default_for_string, True, False