@signature_safe_contextmanager
def scope_guard(scope):
    '\n    Change the global/default scope instance by Python `with` statement. All\n    variable in runtime will assigned to the new scope.\n\n    Args:\n        scope: The new global/default scope.\n\n    Examples:\n        .. code-block:: python\n\n            import paddle.fluid as fluid\n            import numpy\n\n            new_scope = fluid.Scope()\n            with fluid.scope_guard(new_scope):\n                 fluid.global_scope().var("data").get_tensor().set(numpy.ones((2, 2)), fluid.CPUPlace())\n            numpy.array(new_scope.find_var("data").get_tensor())\n    '
    ex = _switch_scope(scope)
    (yield)
    _switch_scope(ex)
Change the global/default scope instance by Python `with` statement. All
variable in runtime will assigned to the new scope.

Args:
    scope: The new global/default scope.

Examples:
    .. code-block:: python

        import paddle.fluid as fluid
        import numpy

        new_scope = fluid.Scope()
        with fluid.scope_guard(new_scope):
             fluid.global_scope().var("data").get_tensor().set(numpy.ones((2, 2)), fluid.CPUPlace())
        numpy.array(new_scope.find_var("data").get_tensor())
@signature_safe_contextmanager
def scope_guard(scope):
    '\n    Change the global/default scope instance by Python `with` statement. All\n    variable in runtime will assigned to the new scope.\n\n    Args:\n        scope: The new global/default scope.\n\n    Examples:\n        .. code-block:: python\n\n            import paddle.fluid as fluid\n            import numpy\n\n            new_scope = fluid.Scope()\n            with fluid.scope_guard(new_scope):\n                 fluid.global_scope().var("data").get_tensor().set(numpy.ones((2, 2)), fluid.CPUPlace())\n            numpy.array(new_scope.find_var("data").get_tensor())\n    '
    ex = _switch_scope(scope)
    (yield)
    _switch_scope(ex)