code: def static_mode_guard():
      """enter static graph mode with `with` statement."""
      premode = "static" if not paddle.in_dynamic_mode() else "dynamic"
  
      if premode == "dynamic":
          paddle.enable_static()
  
      yield
  
      if premode == "dynamic":
          paddle.disable_static()
  
file_path: PaddleHub/paddlehub/compat/paddle_utils.py
imports: import contextlib
  import copy
  from typing import Callable
  from typing import List
  import paddle
  from paddle.framework import core
  from paddlehub.utils.utils import Version
label_desc: Use image node_id 10 for calling a global function with example usage: static_mode_guard() without return types