(*x: Tensor, persistent=False)
*Deprecated. Use `functional_gradient()` instead.*

    Context expression to record gradients for operations within that directly or indirectly depend on `x`.

    The function `gradients()` may be called within the context to evaluate the gradients of a Tensor derived from `x` w.r.t. `x`.

    Args:
        *x: Parameters for which gradients of the form dL/dx may be computed
        persistent: if `False`, `gradients()` may only be called once within the context
*Deprecated. Use `functional_gradient()` instead.*
* Deprecated . Use functional_gradient () instead . *
def record_gradients(*x: Tensor, persistent=False):
    """
    *Deprecated. Use `functional_gradient()` instead.*

    Context expression to record gradients for operations within that directly or indirectly depend on `x`.

    The function `gradients()` may be called within the context to evaluate the gradients of a Tensor derived from `x` w.r.t. `x`.

    Args:
        *x: Parameters for which gradients of the form dL/dx may be computed
        persistent: if `False`, `gradients()` may only be called once within the context
    """
    warnings.warn("math.record_gradients() is deprecated. Use functional_gradient() instead.", DeprecationWarning)
    for x_ in x:
        x_._expand()
    natives = sum([x_._natives() for x_ in x], ())
    backend = choose_backend(*natives)
    ctx = backend.record_gradients(natives, persistent=persistent)
    _PARAM_STACK.append(x)
    ctx.__enter__()
    try:
        yield None
    finally:
        ctx.__exit__(None, None, None)
        _PARAM_STACK.pop(0)
def record_gradients ( * x : Tensor , persistent = False ) : warnings . warn ( "math.record_gradients() is deprecated. Use functional_gradient() instead." , DeprecationWarning ) for x_ in x : x_ . _expand ( ) natives = sum ( [ x_ . _natives ( ) for x_ in x ] , ( ) ) backend = choose_backend ( * natives ) ctx = backend . record_gradients ( natives , persistent = persistent ) _PARAM_STACK . append ( x ) ctx . __enter__ ( ) try : yield None finally : ctx . __exit__ ( None , None , None ) _PARAM_STACK . pop ( 0 )