Hi Saeed!



 saeed_i:

we know Derivation of x^2 is equal to 2x and gradient of y_1 is be 2x


You are making the hidden assumption that y_1[0] depends only
on x[0], y_1[1] only on x[1], and y_1[2] only on x[2].  This
happens to be true in your particular example of y_1 = x.pow (2).
How would you change your reasoning for the case where
y_1 = x * x.roll (1)?
Please look at the concept of the Jacobean matrix and how it is
the generalization of the gradient to a vector-valued function.
(And to avoid any misconception, let me reiterate what I said in
my previous post:  In your current example, y_1 is a vector, rather
than a scalar, so it cannot be used as a loss function.)
Best.
K. Frank