# tensorplay.func.grad_and_value Source: https://www.tensorplay.cn/docs/generated/tensorplay.func.grad_and_value.html ```python tensorplay.func.grad_and_value(func: Callable, argnums: int | tuple[int, ...] = 0, has_aux: bool = False) → Callable ``` Returns a function computing both the gradient of func and its value. The value comes from the same forward pass the gradient needs, so this costs no more than [grad()](/docs/generated/tensorplay.func.grad.html#tensorplay.func.grad) alone and saves evaluating func twice. Returns a function producing (gradient, value), or (gradient, (value, aux)) when has_aux is set.