# Why do we need to pass the gradient parameter to the backward function in PyTorch?

**URL:** <https://discuss.pytorch.org/t/why-do-we-need-to-pass-the-gradient-parameter-to-the-backward-function-in-pytorch/116079>\
**Category:** autograd\
**Created:** [March 26, 2021, 1:47pm UTC](https://discuss.pytorch.org/t/why-do-we-need-to-pass-the-gradient-parameter-to-the-backward-function-in-pytorch/116079 "2021-03-26T13:47:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![AlphaBetaGamma96](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/3da27b/32.png) [@AlphaBetaGamma96](https://discuss.pytorch.org/u/AlphaBetaGamma96)\
**Post date:** [March 26, 2021, 1:56pm UTC](https://discuss.pytorch.org/t/why-do-we-need-to-pass-the-gradient-parameter-to-the-backward-function-in-pytorch/116079/2 "2021-03-26T13:56:53Z")

</div>

I’m pretty sure when you do something like `y.backward(torch.ones_like(y))` you’re just telling autograd to repeat `.backward()` for each element in `y` under the hood.

---

_[View the full topic](https://discuss.pytorch.org/t/why-do-we-need-to-pass-the-gradient-parameter-to-the-backward-function-in-pytorch/116079)._
