def derivate(func, x):
    """Perform autodifferentiation.

    `See more info <https://adel.ac/automatic-differentiation/>`_

    Args:
        func (callable): The objective function to be differentiated. 
        x (list of tensors): Initial conditions.

    Returns:
        tensor, tensor, tensor: Derivative and value function.

    Examples:
        >>> from .functions import rosenbrock
        >>> x = [Variable(FloatTensor([1]), requires_grad=True), Variable(FloatTensor([1]), requires_grad=True)]
        >>> xd1, xd2, y = derivate(rosenbrock, x)
        >>> xd1, xd2
        (tensor([-0.]), tensor([0.]))
        >>> y
        tensor([0.], grad_fn=<AddBackward0>)

    """
    y = func(x)
    y.backward()
    return x[0].grad, x[1].grad, y