A general rule is to avoid explicit for loops when possible.
When manipulating tensors for example, try to vectorize all you can by using the default pytorch functions instead of looping through dimensions.