W3cubDocs

/TensorFlow 2.3

tf.compat.v1.flags.tf_decorator.rewrap

Injects a new target into a function built by make_decorator.

This function allows replacing a function wrapped by decorator_func, assuming the decorator that wraps the function is written as described below.

The decorator function must use <decorator name>.__wrapped__ instead of the wrapped function that is normally used:

Example:

Instead of this:

def simple_parametrized_wrapper(*args, *kwds): return wrapped_fn(args, **kwds)

tf_decorator.make_decorator(simple_parametrized_wrapper, wrapped_fn)

Write this:

def simple_parametrized_wrapper(*args, *kwds): return simple_parametrizedwrapper.wrapped_(args, **kwds)

tf_decorator.make_decorator(simple_parametrized_wrapper, wrapped_fn)

Note that this process modifies decorator_func.

Args
decorator_func Callable returned by wrap.
previous_target Callable that needs to be replaced.
new_target Callable to replace previous_target with.
Returns
The updated decorator. If decorator_func is not a tf_decorator, new_target is returned.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/compat/v1/flags/tf_decorator/rewrap