Hi,
When you do y[0], the Tensor you get is not a leaf tensor anymore.
Remember a leaf Tensor is one that you created with required_grad=True (and so is not the result of an operation).
You can only optimize leaf Tensors.
If you want to use builint optimizers, you will need to create one Tensor for every parameter and combine them during the forward pass:
# Create like this
y0 = torch.ones(1, requires_grad=True)
y1 = torch.ones(1, requires_grad=True)
y2 = torch.ones(1, requires_grad=True)

opt2 = torch.optim.SGD([{'params':[y0],'lr':0.1},{'params':[y1],'lr':1},{'params':[y2],'lr':10}])

# During the forward pass:
y = torch.cat([y0, y1, y2], 0)
# The rest of your forward