Another option is to just clone the previous item in the assignment:
import torch as t

def powers_of_x(N,X):
    Y = t.ones(N)
    for i in range(1,N):
        Y[i] = Y[i-1].clone()*X
    return Y

X = t.tensor([2.0], requires_grad=True)
SERIES = powers_of_x(9,X).sum()

SERIES.backward()
X.grad

output:
tensor([1793.])