I’m sorry but I don’t understand your problem.
You iterate over a tensor? for? In fact when you do that torch enables iteration over the batch size but it’s not usually useful… Numpy does not enable iterators over np.arrays
Anyway you cannot create tensors in the forward pass without breaking the backpropagation.