code: def format(
      _pattern,
      *args,
      stepout=1,
      _quote_all=False,
      quote_func=None,
      **kwargs,
  ):
      """Format a pattern in Snakemake style.
  
      This means that keywords embedded in braces are replaced by any variable
      values that are available in the current namespace.
      """
  
      frame = inspect.currentframe().f_back
      while stepout > 1:
          if not frame.f_back:
              break
          frame = frame.f_back
          stepout -= 1
  
      variables = dict(frame.f_globals)
      # add local variables from calling rule/function
      variables.update(frame.f_locals)
      if "self" in variables and sys.version_info < (3, 5):
          # self is the first arg of fmt.format as well. Not removing it would
          # cause a multiple values error on Python <=3.4.2.
          del variables["self"]
      variables.update(kwargs)
      fmt = SequenceFormatter(separator=" ")
      if _quote_all:
          fmt.element_formatter = AlwaysQuotedFormatter(quote_func)
      else:
          fmt.element_formatter = QuotedFormatter(quote_func)
      try:
          return fmt.format(_pattern, *args, **variables)
      except KeyError as ex:
          if (
              "wildcards" in variables
              and str(ex).strip("'") in variables["wildcards"].keys()
          ):
              raise NameError(
                  "The name '{0}' is unknown in this context. "
                  "Did you mean 'wildcards.{0}'?".format(
                      str(ex).strip("'")
                  )
              )
          raise NameError(
              "The name {} is unknown in this context. Please "
              "make sure that you defined that variable. "
              "Also note that braces not used for variable access "
              "have to be escaped by repeating them, "
              "i.e. {{{{print $1}}}}".format(str(ex))
          )
  
imports: import os
  import json
  import re
  import inspect
  import textwrap
  from itertools import chain
  import collections
  import multiprocessing
  import string
  import shlex
  import sys
  from urllib.parse import urljoin
  from snakemake.io import Namedlist, Wildcards
  from snakemake.common.configfile import _load_configfile
  from snakemake.logging import logger
  from snakemake.common import ON_WINDOWS
  from snakemake.exceptions import WorkflowError
  from snakemake.io import regex_from_filepattern
label_desc: Use image node_id 8 for calling a global function with example usage: format(_pattern) and returns: fmt