Well, @hughperkins  thanks for your comments. Lists are not a pytorch thing, so it may be untraceable. I tried the pytorch thing torch.cat and the code pieces are:
x = torch.randn(4, 4, requires_grad=True)
y = torch.randn(4,4)
for i in range(4):
    if i == 0:
        z = 2*x
    else:
        z = torch.cat((z, z[-4:, :] + x), dim=0)

loss = critetion(z[-4:, :], y)
loss.backward()

However, it is still not true that x.grad = (z[-4:, :] - y)*5*2/16. I got the following prints:

Any comments? @richard @apaszke @SimonW Thanks a lot.