This definitely looks cleaner! But I don’t have a sense of how much more efficient it is. It looks like it though.
Also I dont want to modify the original tensor. So will need to make a clone() first.