I have the following code and the last line is giving me that error. Is there a way I can do indexing copy like numpy?
N, C, H, W = features.size()
gram = torch.zeros((N, C, C))
print(gram.size())
for i in range(N):
    f = features[i, :, :, :]
    print(f.size())
    f = f.view(C, -1)
    print(f.size())
    g = torch.mm(f, f.t())
    print(g.size())
    gram[i, :, :] = g