docstr: Replace frame_dict[name] with new_fn until we exit the context manager.
docstr_tok: ["Replace","frame_dict","[","name","]","with","new_fn","until","we","exit","the","context","manager","."]
code: def patch(
      self,
      frame_dict: Dict[str, Any],
      name: str,
      new_fn: Callable,
      deduplicate: bool = True,
  ):
      """
      Replace frame_dict[name] with new_fn until we exit the context manager.
      """
      new_fn.__fx_already_patched = deduplicate  # type: ignore[attr-defined]
      if name not in frame_dict and hasattr(builtins, name):
          self.patches_made.append(
              _PatchedFnDel(frame_dict, name, None)
          )
      elif getattr(frame_dict[name], "__fx_already_patched", False):
          return  # already patched, no need to do it again
      else:
          self.patches_made.append(
              _PatchedFnSetItem(frame_dict, name, frame_dict[name])
          )
      frame_dict[name] = new_fn
  
imports: import builtins
  import copy
  import functools
  import inspect
  import math
  import os
  import warnings
  import collections
  from itertools import chain
  from types import CodeType, FunctionType, ModuleType
  from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Tuple, Type, Union
  import torch
  import torch.utils._pytree
  from torch._C import ScriptObject
  from ._compatibility import compatibility
  from .graph import _PyTreeCodeGen, _PyTreeInfo, Graph
  from .graph_module import GraphModule
  from .node import Argument, base_types, map_aggregate
  from .proxy import ParameterProxy, Proxy, TracerBase, Scope, ScopeContextManager
label_desc: Use image node_id 2 for calling the _Patcher obj's underlying member method code with example usage: obj.patch(frame_dict, name, new_fn, deduplicate) without return types