<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 What is a Tensor?
Scalar is a single number.
Vector is an array of numbers.
Matrix is a 2-D array of numbers.
Tensors are N-D arrays of numbers.
Step1:  Each variable holds data, a gradient, and information about the function that created it.
<img src="figures/intro_to_pytorch/pytorch_variable.svg",width=400,height=400>
Step2:  Compare the above computations to the below graph.. and then the one below that!
Step3:  Since the derivative of w*x wrt x is w, and vice versa
Step4:  $ y =  2w + b$, since $x = 2$
Say we want
Step5:  Let's compute,  $\displaystyle\frac{\partial}{\partial a}(3a^2 + 2a + 1)$ when $a = 2$ <br>
<ASSISTANT_TASK:>
Python Code:
x = torch.Tensor(5, 3)
print(x)
x.zero_()
torch.Tensor([[1, 2, 3],  # rank 2 tensor
              [4, 5, 6],
              [7, 8, 9]])
x.size()
x = torch.rand(5, 3)
print(x)
npy = np.random.rand(5, 3)
y = torch.from_numpy(npy)
print(y)
z = x + y  #can we do this addition?
x.type(), y.type()
z = x + y.float()
print(z)
torch.add(x, y.float())
x
x.add_(1)
x
x[:2, :2]
x * y.float()
torch.exp(x)
torch.transpose(x, 0, 1)
#transposing, indexing, slicing, mathematical operations, linear algebra, random numbers
torch.trace(x)
x.numpy()
torch.cuda.is_available()
if torch.cuda.is_available():
    x_gpu = x.cuda()
    print(x_gpu)
from torch.autograd import Variable
x = torch.rand(5, 3)
print(x)
x = Variable(torch.rand(5, 3))
print(x)
Explanation: What is a Tensor?
Scalar is a single number.
Vector is an array of numbers.
Matrix is a 2-D array of numbers.
Tensors are N-D arrays of numbers.
End of explanation
x.data
# should be nothing right now
assert x.grad_fn is None
assert x.grad is None
x = Variable(torch.Tensor([2]), requires_grad=True)
w = Variable(torch.Tensor([3]), requires_grad=True)
b = Variable(torch.Tensor([1]), requires_grad=True)
z = x * w
y = z + b
y
Explanation: Each variable holds data, a gradient, and information about the function that created it.
<img src="figures/intro_to_pytorch/pytorch_variable.svg",width=400,height=400>
End of explanation
y.backward()
y, b
Explanation: Compare the above computations to the below graph.. and then the one below that!
End of explanation
w.grad, w
x.grad, x
Explanation: Since the derivative of w*x wrt x is w, and vice versa:
End of explanation
a = Variable(torch.Tensor([2]), requires_grad=True)
Explanation: $ y =  2w + b$, since $x = 2$
Say we want: $\displaystyle\frac{\partial y}{\partial w}$
End of explanation
y = 3*a*a + 2*a + 1
y.backward()
a.grad
Explanation: Let's compute,  $\displaystyle\frac{\partial}{\partial a}(3a^2 + 2a + 1)$ when $a = 2$ <br>
End of explanation
<END_TASK>