Hey,
after analysing my last topic 124823 2, i am convinced that this behavior of autograd/pytorch is not okey. In this code the variable c does not get updated in contrast to a and b after autograd step:
import torch
import torch.optim as optim

# Define a variable w to optimize
w = torch.tensor([1.,2,3,4],requires_grad=True)

# Define variables a and c

a=torch.tensor([2])
c=torch.tensor([3,3])

# Affect values of w to a,b and c

a=w[0]
b=w[0:2]
c[0]=w[0]

# Define optimizer

opt = optim.Adam([w]) 

# Define loss function
loss = w.sum()

# Calculate the gradients
loss.backward()

# Print old values of w, a, b, c
print("w: ",w)
print("a: ",a)
print("b: ",b)
print("c: ",c)

#Optimize

opt.step()



print("=======")
print("After training")
print("=======")

# Print new values of w, a, b, c
print("w: ",w) 
print("a: ",a) # should be updated as well
print("b: ",b) # should be updated as well
print("c: ",c) # should be updated as well