# tensorplay.autograd.backward Source: https://www.tensorplay.cn/docs/generated/tensorplay.autograd.backward.html ```python tensorplay.autograd.backward(tensors: Tensor | Sequence[Tensor], grad_tensors: Tensor | Sequence[Tensor] | None = None, retain_graph: bool | None = None, create_graph: bool = False, grad_variables: Tensor | Sequence[Tensor] | None = None, inputs: Tensor | Sequence[Tensor] | None = None) → None ``` Compute the sum of gradients of given tensors with respect to graph leaves. The gradients are accumulated in the leaves’ .grad. If any of tensors is non-scalar and requires gradient, grad_tensors gives the “vector” of the vector-Jacobian product for each of them (None for scalars and tensors that do not need one). Parameters: - tensors (Sequence[[Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)] or [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – Tensors whose derivative is computed. - grad_tensors (Sequence[[Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) or None] or [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – The “vector” in the vector-Jacobian product, usually gradients w.r.t. each element of corresponding tensors. - retain_graph ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If False, the graph used to compute the grad will be freed. Defaults to the value of create_graph. - create_graph ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If True, the graph of the derivative is constructed, allowing higher order derivative products. - grad_variables (Sequence[[Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) or None] or [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – Deprecated spelling of grad_tensors. - inputs (Sequence[[Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)] or [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) or [dict](https://docs.python.org/3/builtins/stdtypes.html#dict), optional) – Tensors w.r.t. which the gradient will be accumulated into .grad. All other tensors are ignored, and only the part of the graph that leads to these runs. A non-leaf named here keeps its gradient as if it had called retain_grad(). A dict (e.g. dict(model.named_parameters())) names its values.