docstr: Decorator and/or context manager to make temporary changes to a config.
  
  As a decorator:
  
      @config.patch("name", val)
      @config.patch(name1=val1, name2=val2)
      @config.patch({"name1": val1, "name2", val2})
      def foo(...):
          ...
  
  As a context manager:
  
      with config.patch("name", val):
          ...
code: def patch(
      self,
      arg1: Optional[Union[str, Dict[str, Any]]] = None,
      arg2: Any = None,
      **kwargs,
  ):
      """
      Decorator and/or context manager to make temporary changes to a config.
  
      As a decorator:
  
          @config.patch("name", val)
          @config.patch(name1=val1, name2=val2)
          @config.patch({"name1": val1, "name2", val2})
          def foo(...):
              ...
  
      As a context manager:
  
          with config.patch("name", val):
              ...
      """
      changes: Dict[str, Any]
      if arg1 is not None:
          if arg2 is not None:
              assert isinstance(arg1, str)
              # patch("key", True) syntax
              changes = {arg1: arg2}
          else:
              assert isinstance(arg1, dict)
              # patch({"key": True}) syntax
              changes = arg1
          assert not kwargs
      else:
          # patch(key=True) syntax
          changes = kwargs
          assert arg2 is None
      assert isinstance(
          changes, dict
      ), f"expected `dict` got {type(changes)}"
      prior: Dict[str, Any] = {}
      config = self
      dirty = False
  
      class ConfigPatch(ContextDecorator):
          def __enter__(self):
              assert not prior
              nonlocal dirty
              for key in changes.keys():
                  # KeyError on invalid entry
                  prior[key] = config._config[key]
                  dirty = key not in config._compile_ignored_keys
              config._config.update(changes)
              config._is_dirty = dirty
  
          def __exit__(self, exc_type, exc_val, exc_tb):
              nonlocal dirty
              config._config.update(prior)
              config._is_dirty = dirty
              prior.clear()
  
      return ConfigPatch()
  
imports: import contextlib
  import copy
  import hashlib
  import inspect
  import io
  import pickle
  import tokenize
  import unittest
  import warnings
  from types import FunctionType, ModuleType
  from typing import Any, Dict, Optional, Set, Union
  from unittest import mock
label_desc: Use image node_id 12 for calling the ConfigModule obj's underlying member method code with example usage: obj.patch(arg1, arg2) and returns: ConfigPatch