This might break the computation graph, since you are recreating a new tensor array_features.
Could you instead store the outputs of final_kernel in a list and use torch.stack(array_features) after the loop to create a tensor?