Standing for the vector-Jacobian product, returns a tuple containing the
results of func applied to primals and a function that, when
given , computes the reverse-mode Jacobian of with
respect to times .
cotangents
func
primals
cotangents
Parameters:
func (Callable[..., Any]) – A Python function that takes one or more arguments. Must
return one or more Tensors.
primals (Tensors) – Positional arguments to func that must all be
Tensors. The returned function will also be computing the
derivative with respect to these arguments
has_aux (bool) – Flag indicating that func returns a
(output,aux) tuple where the first element is the output of
the function to be differentiated and the second element is
other auxiliary objects that will not be differentiated.
Default: False.
Returns:
Returns a (output,vjp_fn) tuple containing the output of func
applied to primals and a function that computes the vjp of
func with respect to all primals using the cotangents passed
to the returned function. If has_auxisTrue, then instead returns a
(output,vjp_fn,aux) tuple.
The returned vjp_fn function will return a tuple of each VJP.