code: def _push_mode(mode, k: Optional[DispatchKey] = None):
      assert k is None or k == torch._C.DispatchKey.PreDispatch
      if k is None:
          _push_on_torch_dispatch_stack(mode)
          return
  
      from torch._ops import get_cached_ops, _set_mode_pre_dispatch
  
      # See Note [Not Caching Per-Dispatch-Key Mode Handlers]
      # Clear the cache of every op that has been used so far, for this particular key.
      ks = torch._C._functionality_to_backend_keys(k)
      for op in get_cached_ops():
          for key in ks:
              op._uncache_dispatch(key)
      _set_mode_pre_dispatch(mode)
  
imports: import contextlib
  from typing import Optional, Union, List, Set, Dict, Any
  import warnings
  from dataclasses import dataclass
  import torch
  import torchgen
  from torch._C import _len_torch_dispatch_stack, _get_dispatch_stack_at, _pop_torch_dispatch_stack, _push_on_torch_dispatch_stack, DispatchKey
label_desc: Use image node_id 4 for calling a global function with example usage: _push_mode(mode, k) without return types