How to ditermine shape of param that was sent to backward

In the official tutorial, I see that the shape of param that was put in backward is the same as input like below

gradients = torch.tensor([0.1, 1.0, 0.0001], dtype=torch.float)


But in another page,

out.backward(torch.randn(1, 10))

The param put in backward share the shape of output, can anyone give my any help?