iterate over tensor using for loop