By default the gradients will be accumulated.
If you call N times backward on your output, the N gradients will be summed in for your parameters.
w = nn.Parameter(torch.ones(1))
x = torch.ones(1) * 2

for _ in range(3):
    output = x * w
    output.backward()
    print(w.grad)

> tensor([2.])
> tensor([4.])
> tensor([6.])

If you need to compute the gradients several times, you might scale your learning rate a bit down, but of course this depends on your use case, the model etc.