def _wrapped_unary_to_nary(func): """Use functools.wraps with unary_to_nary decorator.""" if AUTOGRAD_AVAILABLE: return wraps(func)(unary_to_nary(func)) else: return func
# See the License for the specific language governing permissions and # limitations under the License. """ This module contains the autograd wrappers :class:`grad` and :func:`jacobian` """ import numpy as onp from pennylane import numpy as np from functools import partial from autograd.core import make_vjp as _make_vjp from autograd.wrap_util import unary_to_nary from autograd.extend import vspace from autograd import jacobian as _jacobian make_vjp = unary_to_nary(_make_vjp) class grad: """Returns the gradient as a callable function of (functions of) QNodes. Function arguments with the property ``requires_grad`` set to ``False`` will automatically be excluded from the gradient computation, unless the ``argnum`` keyword argument is passed. When the output gradient function is executed, both the forward pass *and* the backward pass will be performed in order to compute the gradient. The value of the forward pass is available via the :attr:`~.forward` property. Args:
def _wrapped_unary_to_nary(func): """Use functools.wraps with unary_to_nary decorator.""" return wraps(func)(unary_to_nary(func))