code: def with_flags(**flags):
      @decorator
      def wrapper(func, *args, **kwargs):
          prev_flags = hl._get_flags(*flags)
  
          hl._set_flags(**{k: v for k, v in flags.items()})
  
          try:
              return func(*args, **kwargs)
          finally:
              hl._set_flags(**prev_flags)
  
      return wrapper
  
imports: from typing import Callable, TypeVar
  from typing_extensions import ParamSpec
  import os
  from timeit import default_timer
  import unittest
  import pytest
  from hailtop.hail_decorator import decorator
  from hail.utils.java import choose_backend
  import hail
label_desc: Use image node_id 22 for calling a global function with example usage: with_flags() and returns: wrapper, func