This is related to python3 and not explicitly to pytorch
But anyway to answer your question.
>>> for i, val in enumerate([10, 20, 30, 40, 50]):
>>>  print (i, val)
0, 10
1, 20
2, 30
3, 40
4, 50

Also,
In [13]: d = np.array([[4, 5], [6, 7]])
In [14]: for i, val in enumerate(d):
              print (i, val)
0 [4 5]
1 [6 7]

So, basically in your example, all you are doing is you are multiplying each dimension with its index. And hence the shape is preserved.