what does gradient argument do in backward()?
I make a test by the following case.
import torch
from torch.autograd import Variable

x = Variable(torch.ones(2, 3), requires_grad=True)
a = Variable(torch.ones(3, 4))
out = torch.mm(x,a)    # shape: (2,4)

gradient = torch.FloatTensor([[1,2,3,4],[5,6,7,8]]) # shape=(2,4)
#gradient = torch.ones(4, 4)
out.backward(gradient)
print(x.grad)


x




x_11
x_12
x_13




x_21
x_22
x_23



out




x_11+x_12+x_13
x_11+x_12+x_13
x_11+x_12+x_13
x_11+x_12+x_13




x_21+x_22+x_23
x_21+x_22+x_23
x_21+x_22+x_23
x_21+x_22+x_23



gradient*out




x_11+x_12+x_13
2x_11+2x_12+2x_13
3x_11+3x_12+3x_13
4x_11+4x_12+4x_13




5x_21+5x_22+5x_23
6x_21+6x_22+6x_23
7x_21+7x_22+7x_23
8x_21+8x_22+8x_23



x.grad
Variable containing:
 10  10  10
 26  26  26

10 = 1+2+3+4+0+0+0+0
26=0+0+0+0+5+6+7+8

I find that, gradient will perform a dot product on output in the above case.
What is the objective of this operation?